:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(taxonomic-filter): keep stale popover definition out of getIcon (#125757)
Steven Shults23b51f7d9a16
diff --git a/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx b/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsxindex b42b76c3908d..b8d3bfeed8bf 100644--- a/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx+++ b/frontend/src/lib/components/DefinitionPopover/DefinitionPopoverContents.tsx@@ -728,10 +728,12 @@ export function ControlledDefinitionPopover({highlightedItemElement,definitionPopoverRenderer,}: ControlledDefinitionPopoverContentsProps): JSX.Element | null {- const { state, singularType, definition } = useValues(definitionPopoverLogic)+ const { state, singularType } = useValues(definitionPopoverLogic)const { setDefinition } = useActions(definitionPopoverLogic)- const icon = group.getIcon?.(definition || item)+ // Not definition: the effect below syncs it after render, so for one render it can hold another group's+ // row, and a getIcon that reads its own row shape ("On this page" reads option.icon) then crashes.+ const icon = group.getIcon?.(item)// Supports all types specified in selectedItemHasPopover// Pinned items store minimal data ({ name }) so the source group's getValue may notdiff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsxindex eef89c2e16f0..222fee3f5aa4 100644--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx@@ -1156,6 +1156,29 @@ describe('TaxonomicFilter', () => {}).not.toThrow()})+ it('shows the popover when the highlight moves from an event to an "On this page" match', async () => {+ renderFilter({+ groupType: TaxonomicFilterGroupType.MaxAIContext,+ taxonomicGroupTypes: [TaxonomicFilterGroupType.MaxAIContext, TaxonomicFilterGroupType.Events],+ maxContextOptions: [+ { id: 'insight-1', value: 'insight-1', name: 'event conversion', icon: () => <span /> },+ ],+ popoverEnabled: true,+ })+ await userEvent.click(screen.getByTestId('taxonomic-tab-suggested_filters'))+ // Real timers: with withoutDebounceDelay the All list stays empty after the search.+ await userEvent.type(screen.getByTestId('taxonomic-filter-searchfield'), 'event')++ // The popover logic is shared by every row, so on the first render after the move it+ // still holds the event's definition while the group is already "On this page".+ const popoverHeader = (): Element | null => document.querySelector('.definition-popover-header-row-title')+ await userEvent.hover(await screen.findByTestId('prop-filter-suggested_filters-1'))+ await waitFor(() => expect(popoverHeader()).toHaveTextContent('Unverified event'))+ await userEvent.hover(screen.getByTestId('prop-filter-suggested_filters-0'))++ await waitFor(() => expect(popoverHeader()).toHaveTextContent('On this page'))+ })+it('renders correctly when search matches no items', async () => {renderFilter()