fix(search-filters): prevent nested filter dropdowns from disappearing on reopen#2421
Conversation
…g on reopen
In Mantine v9, the Accordion Panel uses a Collapse component that
transitions through display:none state. NestedFilterGroup previously used
{isExpanded && ...} to conditionally mount its content inside the Panel.
This caused the virtualizer's scroll element to be inside a display:none
container when reopening, resulting in zero dimensions from
getBoundingClientRect(). With no viewport size, the virtualizer rendered
zero items, making the dropdown appear empty.
The fix removes the conditional mount guard. The virtualizer already uses
count: isExpanded ? childFilters.length : 0 to control rendering, so no
items are rendered when collapsed. The Accordion Panel's built-in Collapse
animation handles visibility. When reopening, the scroll element is
already in the DOM, allowing the virtualizer's ResizeObserver to detect
dimension changes and render items correctly.
Fixes: HDX-4471
Co-authored-by: Mike Shi <mike@hyperdx.io>
🦋 Changeset detectedLatest commit: de1ec84 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
E2E Test Results✅ All tests passed • 198 passed • 3 skipped • 1286s
Tests ran across 4 shards in parallel. |
|
Tested and works, thanks! |
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Deep Review✅ No critical issues found. The fix is sound: removing the 🟡 P2 — recommended
🔵 P3 nitpicks (3)
Pre-existing (not introduced by this diff)
Reviewers (9): correctness, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, performance, agent-native, learnings-researcher. Testing gaps:
|
Summary
Nested filter dropdowns in ClickStack Search (e.g.
ResourceAttributes,LogAttributes) showed no filters after being closed and reopened.Root Cause
The bug was introduced by PR #2096 (Mantine v7 to v9 upgrade). In Mantine v9,
Accordion.Paneluses aCollapsecomponent that transitions throughdisplay: nonestate when closed. TheNestedFilterGroupcomponent previously used{isExpanded && ...}to conditionally mount its panel content, including the scroll container used by@tanstack/react-virtual.When reopening:
isExpandedbecomes true - content mounts inside the Paneldisplay: none(until an asyncrequestAnimationFramefires)useLayoutEffectand callsgetBoundingClientRect()- returns{width: 0, height: 0}because the element is insidedisplay: noneouterSize = 0, the virtualizer'scalculateRange()returnsnull-getVirtualItems()returns[]In Mantine v7, this pattern worked because the Panel either fully unmounted its content or didn't transition through
display: none, so the virtualizer always had valid dimensions when content was present.Fix
Remove the
{isExpanded && ...}conditional wrapper fromNestedFilterGroup. The scroll container now stays mounted inside theAccordion.Panelat all times, maintaining the virtualizer's connection to it.This is safe because:
count: isExpanded ? childFilters.length : 0to prevent rendering items when collapsedAccordion.Panel's built-inCollapseanimation handles visibilityResizeObserverdetects the scroll element's dimension change (fromdisplay: nonetodisplay: block) and the virtualizer renders items correctlyTesting
Linear Issue: HDX-4471