Skip to content

: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.

fix(taxonomic-filter): name the matching category in the empty state again (#117915)

Paul D'Ambra935502081fc4
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 60487a4e5793..6e5a30cb60fb 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -3628,6 +3628,10 @@ snapshots:
hash: v1.k794b7964.56b8792ce05a2bd6639b561f1330df09e67cf01fa9307301aa91560ff69442dd.mnfSSv24JeDgvtTRf6YX_-olqjQUQIzvd7GVi6CFMNU
filters-taxonomic-filter--empty-events-with-value-hint--light:
hash: v1.k794b7964.97ddd61650806011675ac41c4ca31e0409b894993096eaa1e645e5748502be1a.NtvmxNSJzpPc-osNFNOzk85H2kVtbmQKDUClTvwYPfA
+ filters-taxonomic-filter--empty-tab-with-jumps-to-other-categories--dark:
+ hash: v1.k794b7964.cb129e04c8d6a9e6c4603e87a645e9bb1136bb222f0fdfcf53e25b1e32983873.43FF8fvDP9re3M194WgDHHJxMQvZsCWKfVt122ELNHg
+ filters-taxonomic-filter--empty-tab-with-jumps-to-other-categories--light:
+ hash: v1.k794b7964.8f51c139da9698fb2cb652e0703c4a363a4b69b5cc027fb31668dcb9853e0b97.BOiCdx3Mx2E44hxeIqqDbL0HtInOBvE_HVS8W2l44n4
filters-taxonomic-filter--events-free--dark:
hash: v1.k794b7964.66ffbc1a41e65685646edaa051c0112d431e5f99dcca205d6a62f2bd3ce60f4c.9sxt-JbSQIxs9w_imI-y34flHbdgcsTC57Md7yFCVzM
filters-taxonomic-filter--events-free--light:
diff --git a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
index 1ce23a0cd163..d3a138348e5b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/InfiniteList.tsx
@@ -754,11 +754,12 @@ function InfiniteListEmptyState(): JSX.Element {
taxonomicGroupTypes.includes(TaxonomicFilterGroupType.SuggestedFilters) &&
allSectionHasResults
+ // Named jumps come first because they say where the match is. The "all" jump stays as the fallback.
// 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
+ !emptySearchQuery && !isSuggestedFilters
? taxonomicGroupTypes.filter(
(groupType) =>
groupType !== listGroupType &&
@@ -831,22 +832,6 @@ function InfiniteListEmptyState(): JSX.Element {
Include stale events
</LemonButton>
)}
- {canOfferAllSwitch && (
- <LemonButton
- type="secondary"
- size="xsmall"
- data-attr="taxonomic-switch-to-all"
- onClick={() => {
- reportTaxonomicFilterCategorySelected(
- TaxonomicFilterGroupType.SuggestedFilters,
- eventNames?.[0]
- )
- setActiveTab(TaxonomicFilterGroupType.SuggestedFilters)
- }}
- >
- 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 (
@@ -864,6 +849,22 @@ function InfiniteListEmptyState(): JSX.Element {
</LemonButton>
)
})}
+ {canOfferAllSwitch && (
+ <LemonButton
+ type="secondary"
+ size="xsmall"
+ data-attr="taxonomic-switch-to-all"
+ onClick={() => {
+ reportTaxonomicFilterCategorySelected(
+ TaxonomicFilterGroupType.SuggestedFilters,
+ eventNames?.[0]
+ )
+ setActiveTab(TaxonomicFilterGroupType.SuggestedFilters)
+ }}
+ >
+ See results from other categories
+ </LemonButton>
+ )}
</>
)}
</div>
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
index dab5b3b615ae..aa0ca7440037 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.stories.tsx
@@ -873,6 +873,46 @@ export const EmptyEventsWithStaleToggle: Story = {
},
}
+export const EmptyTabWithJumpsToOtherCategories: Story = {
+ render: (args) => {
+ useMountedLogic(actionsModel)
+ const { setSearchQuery, setActiveTab } = useActions(
+ taxonomicFilterLogic({ ...args, taxonomicFilterLogicKey: args.taxonomicFilterLogicKey as string })
+ )
+
+ useOnMountEffect(() => {
+ setSearchQuery('plan')
+ setActiveTab(TaxonomicFilterGroupType.Events)
+ })
+
+ return (
+ <div className="w-fit border rounded p-2 bg-surface-primary">
+ <TaxonomicFilter {...args} />
+ </div>
+ )
+ },
+ args: {
+ taxonomicFilterLogicKey: 'empty-tab-jumps',
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.EventProperties],
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/event_definitions': [],
+ },
+ }),
+ ],
+ parameters: {
+ // Hidden tabs stay mounted and render the same jumps, so wait for the one on the open tab.
+ testOptions: { waitForSelector: '[data-attr="taxonomic-switch-to-all"] >> visible=true' },
+ docs: {
+ description: {
+ story: 'When the open tab has no results but another category does, the empty state names that category, with a jump to all categories as the fallback.',
+ },
+ },
+ },
+}
+
function EventMatchStoryRender({
resetMatches = false,
...args
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
index a9eeb3f73b00..7d3cc05e1b9a 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
@@ -482,7 +482,7 @@ describe('TaxonomicFilter', () => {
await userEvent.click(screen.getByTestId(testId))
}
- it('offers a button to jump to the all section when another group has matches', async () => {
+ it('offers jumps to the matching group and to the all section when another group has matches', async () => {
renderFilter({
taxonomicGroupTypes: [
TaxonomicFilterGroupType.SuggestedFilters,
@@ -506,6 +506,10 @@ describe('TaxonomicFilter', () => {
expect(switchButton).toBeTruthy()
})
expect(switchButton).toHaveTextContent(/See results from other categories/i)
+ // The named jump says where the match is, so it shows too, above the "all" fallback.
+ const eventsButton = inVisibleTab(screen.getAllByTestId('taxonomic-switch-to-events'))
+ expect(eventsButton).toHaveTextContent(/See results in Events/i)
+ expect(eventsButton!.compareDocumentPosition(switchButton!)).toBe(Node.DOCUMENT_POSITION_FOLLOWING)
await userEvent.click(switchButton!)