From eb477b73dea1cb074f27d630685f1548641e08a9 Mon Sep 17 00:00:00 2001 From: "Rob J. Caskey" Date: Wed, 11 Nov 2026 11:39:24 -0500 Subject: [PATCH 1/4] fix(ui/search): tell same-named containers apart in filter options Container filter options were labelled with the container's name only, so a "store" schema in two databases showed up as two identical "store" entries. When options on offer share a name, prefix each with the fewest parent containers that tell them apart (the database first, then higher levels), as a dotted path. A long path keeps the parent that tells it apart and the container's own name, collapses the levels between them to an ellipsis and shortens over-long names in the middle; hovering an ellipsis shows what it hides and hovering the rest shows the full path. Options with a unique name are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../src/app/searchV2/filters/FilterOption.tsx | 57 +++++++- .../filters/__tests__/FilterOption.test.tsx | 25 ++++ .../__tests__/containerDisambiguation.test.ts | 127 ++++++++++++++++++ .../filters/containerDisambiguation.ts | 116 ++++++++++++++++ .../app/searchV2/filters/mapFilterOption.tsx | 3 + .../filters/value/EntityValueMenu.tsx | 7 + .../value/__tests__/EntityValueMenu.test.tsx | 69 ++++++++++ 7 files changed, 402 insertions(+), 2 deletions(-) create mode 100644 datahub-web-react/src/app/searchV2/filters/__tests__/FilterOption.test.tsx create mode 100644 datahub-web-react/src/app/searchV2/filters/__tests__/containerDisambiguation.test.ts create mode 100644 datahub-web-react/src/app/searchV2/filters/containerDisambiguation.ts create mode 100644 datahub-web-react/src/app/searchV2/filters/value/__tests__/EntityValueMenu.test.tsx diff --git a/datahub-web-react/src/app/searchV2/filters/FilterOption.tsx b/datahub-web-react/src/app/searchV2/filters/FilterOption.tsx index 08ab65d6ccb9f..87e78426e6608 100644 --- a/datahub-web-react/src/app/searchV2/filters/FilterOption.tsx +++ b/datahub-web-react/src/app/searchV2/filters/FilterOption.tsx @@ -1,10 +1,11 @@ -import { Checkbox, Pill } from '@components'; +import { Checkbox, Pill, Tooltip } from '@components'; import { CaretUp } from '@phosphor-icons/react/dist/csr/CaretUp'; import React, { useState } from 'react'; import styled from 'styled-components'; import { generateColor } from '@app/entityV2/shared/components/styled/StyledTag'; import ParentEntities from '@app/searchV2/filters/ParentEntities'; +import { getContainerPathSegments, getFullContainerPath } from '@app/searchV2/filters/containerDisambiguation'; import { Label } from '@app/searchV2/filters/styledComponents'; import { FilterOptionType } from '@app/searchV2/filters/types'; import { @@ -20,6 +21,7 @@ import { TYPE_NAMES_FILTER_NAME, } from '@app/searchV2/utils/constants'; import { formatNumber } from '@app/sharedV2/formatNumber'; +import { SingleEntityIcon } from '@app/searchV2/autoCompleteV2/components/icon/SingleEntityIcon'; import { EntitySelectOption } from '@app/sharedV2/select/EntitySelectOption'; import { capitalizeFirstLetterOnly } from '@app/sharedV2/textUtil'; import { useEntityRegistry } from '@app/useEntityRegistry'; @@ -89,6 +91,26 @@ const LabelWrapper = styled.div` line-height: normal; `; +// getContainerPathSegments keeps paths short; the overflow rules are only a backstop for wide glyphs. +const ContainerPath = styled.span` + display: block; + max-width: 240px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +`; + +const ContainerOption = styled.div` + display: flex; + align-items: center; + gap: 8px; + min-width: 0; +`; + +const ElidedSegment = styled.span` + cursor: help; +`; + interface Props { filterOption: FilterOptionType; selectedFilterOptions: FilterOptionType[]; @@ -96,6 +118,8 @@ interface Props { nestedOptions?: FilterOptionType[]; addPadding?: boolean; includeCount?: boolean; + // Parent containers (nearest first) to prefix to the label so it differs from same-named options. + containerParents?: Entity[]; } export default function FilterOption({ @@ -105,10 +129,12 @@ export default function FilterOption({ nestedOptions, addPadding, includeCount = true, + containerParents, }: Props) { const [areChildrenVisible, setAreChildrenVisible] = useState(true); const { field, value, count, entity } = filterOption; const entityRegistry = useEntityRegistry(); + const getEntityLabel = (e: Entity) => entityRegistry.getDisplayName(e.type, e); const { label } = getFilterIconAndLabel(field, value, entityRegistry, entity || null, 14, filterOption.displayName); const showParentEntityPath = field === DOMAINS_FILTER_NAME && entity?.type === EntityType.Domain; const isSubTypeFilter = field === TYPE_NAMES_FILTER_NAME; @@ -145,7 +171,34 @@ export default function FilterOption({ )} - {filterOption.entity ? ( + {entity && containerParents?.length ? ( + + + + {getContainerPathSegments( + getEntityLabel(entity), + containerParents, + getEntityLabel, + ).map((segment, index) => { + const text = index ? `.${segment.text}` : segment.text; + return ( + + {segment.hidden ? ( + + {text} + + ) : ( + {text} + )} + + ); + })} + + + ) : filterOption.entity ? ( ) : (