From 4886d9d4afbbba5067b8648d93f5b66ea51f7cfd Mon Sep 17 00:00:00 2001 From: darth-coder00 <86726556+darth-coder00@users.noreply.github.com> Date: Fri, 10 Jun 2022 00:50:43 +0530 Subject: [PATCH] Fix #4954: UI: Breadcrumb layout breaks with long table names (#5385) * Fix #4954: UI: Breadcrumb layout breaks with long table names * Fixing code smells Co-authored-by: Vivek Ratnavel Subramanian --- .../Glossary/GlossaryV1.component.tsx | 34 +++++++++- .../common/entityPageInfo/EntityPageInfo.tsx | 25 ++++++-- .../title-breadcrumb.component.tsx | 63 +++++++++++++++++-- .../title-breadcrumb.interface.ts | 1 + .../resources/ui/src/hooks/useAfterMount.ts | 28 +++++++++ 5 files changed, 138 insertions(+), 13 deletions(-) create mode 100644 openmetadata-ui/src/main/resources/ui/src/hooks/useAfterMount.ts diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryV1.component.tsx index f2296078443..24d3ab33458 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Glossary/GlossaryV1.component.tsx @@ -25,6 +25,7 @@ import { TITLE_FOR_NON_ADMIN_ACTION } from '../../constants/constants'; import { Glossary } from '../../generated/entity/data/glossary'; import { GlossaryTerm } from '../../generated/entity/data/glossaryTerm'; import { useAuth } from '../../hooks/authHooks'; +import { useAfterMount } from '../../hooks/useAfterMount'; import { ModifiedGlossaryData } from '../../pages/GlossaryPage/GlossaryPageV1.component'; import { getEntityDeleteMessage } from '../../utils/CommonUtils'; import { generateTreeData } from '../../utils/GlossaryUtils'; @@ -110,6 +111,15 @@ const GlossaryV1 = ({ >([]); const [showActions, setShowActions] = useState(false); const [isDelete, setIsDelete] = useState(false); + const [addTermButtonWidth, setAddTermButtonWidth] = useState( + document.getElementById('add-term-button')?.offsetWidth || 0 + ); + const [manageButtonWidth, setManageButtonWidth] = useState( + document.getElementById('manage-button')?.offsetWidth || 0 + ); + const [leftPanelWidth, setLeftPanelWidth] = useState( + document.getElementById('glossary-left-panel')?.offsetWidth || 0 + ); /** * To create breadcrumb from the fqn @@ -163,10 +173,23 @@ const GlossaryV1 = ({ handleBreadcrum(selectedKey); }, [selectedKey]); + useAfterMount(() => { + setLeftPanelWidth( + document.getElementById('glossary-left-panel')?.offsetWidth || 0 + ); + setAddTermButtonWidth( + document.getElementById('add-term-button')?.offsetWidth || 0 + ); + setManageButtonWidth( + document.getElementById('manage-button')?.offsetWidth || 0 + ); + }); + const manageButtonContent = () => { return (
setIsDelete(true)}>
{ return ( -
+
Glossary
@@ -256,9 +279,14 @@ const GlossaryV1 = ({
- +
-
+