fix(ui/search): tell same-named containers apart in filter options

RO
25m ago
+1162-11

Before this PR, the Container filter's option list labels each container by its name only, so a store schema in two databases shows up as two identical store entries and users can't tell which one they are picking; with this PR, options that share a name are prefixed with the fewest parent containers that tell them apart (the database first, then higher levels), shown as a dotted path such as petshop_east.store; long paths stay readable (lakehouse_a.….supply, petsho…to_2024.store) and the hidden parts show on hover.

What changes

  • Only colliding options change. A container whose name is unique among the options on offer keeps its plain name, so the list grows only where it has to.
  • The comparison is against the options currently on offer in that menu, so the same container can be shown plainly in one list and with its database in another.
  • If no level tells a group apart (the same names all the way up), each option shows its whole parent path.
  • Long paths keep the two parts that matter: the parent that tells the options apart and the container's own name. Levels between them collapse to …, and a name too long on its own is shortened in the middle, so names that differ only at the start or end (…_2019_to_2024 vs …_2014_to_2018) stay apart. Hovering an ellipsis shows what it hides; hovering the rest of the path shows the full path. The row never scrolls sideways.
  • This covers every place that uses the entity value menu for containers: the value menu of an applied Container filter, Add filter → Container, and the View builder.

How

The search, autocomplete and facet queries behind these menus already fetch parentContainers for containers, so this is UI-only:

  • searchV2/filters/containerDisambiguation.ts (new): groups container options by name and finds the minimal disambiguating depth per group; getContainerPathSegments turns a path into display segments within a character budget, each ellipsis carrying the text it hides.
  • EntityValueMenu computes it over the options on offer and passes each option its parents through mapFilterOption to FilterOption, which renders each segment with its own tooltip.

No GraphQL, backend or config changes; no new UI strings.

Testing

  • Playwright tests/search-container-filter/container-filter-disambiguation.spec.ts with petshop sample containers: same-named schemas in two databases, same-named databases in two catalogs (a collapsed path, checking both hover tooltips), and a unique name. Passes with this PR at 32ff5120d55 (4 of 4). Also checked by hand with 60–90 character names and a six-level chain: every option stays distinct and nothing overflows.
  • Unit: containerDisambiguation.test.ts (grouping, depth, unique names, non-container options, identical chains, path formatting, collapsing and middle-shortening long paths), EntityValueMenu.test.tsx (labels rendered end to end, including shortened ones), FilterOption.test.tsx. 100% of changed lines covered.
  • Lint and type-check clean (:datahub-web-react:yarnLint, :e2e-test:ui:playwright:lint).

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
  • Tests for the changes have been added/updated
  • Docs related to the changes have been added/updated (not needed: display-only change)
  • Breaking changes (none)

🤖 Generated with Claude Code


Summary by cubic

Fixes the Container filter option list so same-named containers are told apart, and search can find them by a parent name.

  • Colliding options are prefixed with the fewest parent containers (database first) that separate them, shown as a dotted path such as petshop_east.store; unique names stay plain.
  • Long paths keep the levels that differ, collapse only the levels the whole group shares to an ellipsis, and skip shortening when shortened names would look alike; hovering an ellipsis shows what it hides and hovering the rest shows the full path.
  • The prefix depends on the options currently on offer in that menu, so the same container can appear plainly in one list and prefixed with its database in another.
  • The value menu's search now matches containers on their full path, so typing a parent shown in a label (petshop_east) keeps that option.
  • UI-only: the search, autocomplete, and facet queries already fetch parentContainers, so no GraphQL, backend, or config changes.