: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): surface cross-tab matches in empty state (#66686)
posthog[bot]32e58aede023
diff --git a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsxindex 16c5fc3cc1d2..a90a9ded4729 100644--- a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx@@ -653,9 +653,21 @@ export const InfiniteListRow = ({)}+// Cap on the number of "found in X" jump buttons rendered in the empty state, to keep it tidy+// when a search matches across many categories.+const MAX_OTHER_GROUP_SWITCHES = 3+function InfiniteListEmptyState(): JSX.Element {- const { searchQuery, taxonomicGroupTypes, includeStaleEvents, infiniteListCounts, eventNames } =- useValues(taxonomicFilterLogic)+ const {+ searchQuery,+ taxonomicGroups,+ taxonomicGroupTypes,+ metaGroupTypes,+ includeStaleEvents,+ infiniteListCounts,+ infiniteListResultCounts,+ eventNames,+ } = useValues(taxonomicFilterLogic)const { setIncludeStaleEvents, setActiveTab } = useActions(taxonomicFilterLogic)const { reportTaxonomicFilterCategorySelected } = useActions(eventUsageLogic)@@ -677,6 +689,21 @@ function InfiniteListEmptyState(): JSX.Element {!isSuggestedFilters &&taxonomicGroupTypes.includes(TaxonomicFilterGroupType.SuggestedFilters) &&allSectionHasResults++ // Without the aggregated "all" tab (e.g. the control variant, which doesn't inject SuggestedFilters),+ // there's no single place to jump to — so surface the specific categories that do have matches.+ // Keyed off result counts (not `infiniteListCounts`/`totalListCount`) so render-backed groups like+ // the SQL expression editor, whose affordance row makes `totalListCount` non-zero for any query,+ // don't produce a misleading "See results in …" jump.+ const otherGroupTypesWithResults =+ !emptySearchQuery && !isSuggestedFilters && !canOfferAllSwitch+ ? taxonomicGroupTypes.filter(+ (groupType) =>+ groupType !== listGroupType &&+ !metaGroupTypes.has(groupType) &&+ (infiniteListResultCounts[groupType] ?? 0) > 0+ )+ : []return (<div className="no-infinite-results flex flex-col gap-y-1 items-center">{suggestedFiltersBeforeSearching ? (@@ -734,6 +761,23 @@ function InfiniteListEmptyState(): JSX.Element {See results from other categories</LemonButton>)}+ {otherGroupTypesWithResults.slice(0, MAX_OTHER_GROUP_SWITCHES).map((groupType) => {+ const groupName = taxonomicGroups.find((g) => g.type === groupType)?.name ?? groupType+ return (+ <LemonButton+ key={groupType}+ type="secondary"+ size="xsmall"+ data-attr={`taxonomic-switch-to-${groupType}`}+ onClick={() => {+ reportTaxonomicFilterCategorySelected(groupType, eventNames?.[0])+ setActiveTab(groupType)+ }}+ >+ See results in {groupName}+ </LemonButton>+ )+ })}</>)}</div>diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsxindex c6759fa4164a..dabc1615cde4 100644--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx@@ -336,6 +336,54 @@ describe('TaxonomicFilter', () => {})expect(screen.queryByTestId('taxonomic-switch-to-all')).not.toBeInTheDocument()})++ it('offers a per-category jump when matches live on another tab and there is no all section', async () => {+ // No SuggestedFilters group (control variant), so the aggregated "all" jump is unavailable —+ // the empty state must instead point at the specific tab that matched.+ renderFilter({+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.PersonProperties],+ })++ await activateGroupWithResults('taxonomic-tab-events')+ // `purchase_value` exists only as a property, so the active Events tab comes up empty+ await userEvent.type(screen.getByTestId('taxonomic-filter-searchfield'), 'purchase_value')++ let switchButton: HTMLElement | undefined+ await waitFor(() => {+ switchButton = inVisibleTab(screen.getAllByTestId('taxonomic-switch-to-person_properties'))+ expect(switchButton).toBeTruthy()+ })+ expect(switchButton).toHaveTextContent(/See results in Person properties/i)+ expect(screen.queryByTestId('taxonomic-switch-to-all')).not.toBeInTheDocument()++ await userEvent.click(switchButton!)++ await waitFor(() => {+ expectActiveTab('taxonomic-tab-person_properties')+ })+ })++ it('does not offer a jump to a render-backed group with no real matches', async () => {+ // SQL expression is render-backed: its affordance row makes totalListCount non-zero for+ // any query, but it has no actual search results. It must not produce a bogus jump button.+ renderFilter({+ taxonomicGroupTypes: [+ TaxonomicFilterGroupType.Events,+ TaxonomicFilterGroupType.PersonProperties,+ TaxonomicFilterGroupType.HogQLExpression,+ ],+ })++ await activateGroupWithResults('taxonomic-tab-events')+ await userEvent.type(screen.getByTestId('taxonomic-filter-searchfield'), 'purchase_value')++ // The genuinely-matching tab is still offered...+ await waitFor(() => {+ expect(inVisibleTab(screen.getAllByTestId('taxonomic-switch-to-person_properties'))).toBeTruthy()+ })+ // ...but the render-backed SQL expression tab is not.+ expect(screen.queryByTestId('taxonomic-switch-to-hogql_expression')).not.toBeInTheDocument()+ })})describe('tab switching', () => {diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsxindex 962245baed8d..ef3ecfa93d7c 100644--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx@@ -1672,6 +1672,23 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([(infiniteListCounts) => infiniteListCounts,{ resultEqualityCheck: objectsEqual },],+ // Like `infiniteListCounts` but counts only genuine search results (`totalResultCount`),+ // excluding the affordance rows `totalListCount` adds for render-backed groups (e.g. the+ // SQL expression editor) and "see more" expanders. Use this when deciding whether a tab+ // actually matched the query — `totalListCount` is non-zero for a render group on any query.+ infiniteListResultCounts: [+ (s) => [+ (state, props) =>+ Object.fromEntries(+ Object.entries(s.infiniteListLogics(state, props)).map(([groupType, logic]) => [+ groupType,+ logic.isMounted() ? logic.selectors.totalResultCount(state, logic.props) : 0,+ ])+ ),+ ],+ (infiniteListResultCounts) => infiniteListResultCounts,+ { resultEqualityCheck: objectsEqual },+ ],value: [() => [(_, props) => props.value], (value) => value],groupType: [() => [(_, props) => props.groupType], (groupType) => groupType],activeTab: [