: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): stop false "No results" flash on the All tab (#69978)
posthog[bot]b6e51d4c1209
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.tsindex 554c418776be..db412d24065b 100644--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.test.ts@@ -1,5 +1,6 @@import { MOCK_TEAM_ID } from 'lib/api.mock'+import { getContext } from 'kea'import { expectLogic, partial } from 'kea-test-utils'import posthog from 'posthog-js'@@ -576,6 +577,77 @@ describe('infiniteListLogic', () => {})})+ describe('SuggestedFilters aggregate holds the empty state until sibling groups settle', () => {+ // Regression for the false "No results" flash while typing on the aggregated "All" tab.+ // That tab runs no fetch of its own, so it can only tell it has settled by watching its+ // sibling group lists. It used to gate solely on the transient `anyGroupLoading` boolean,+ // which dips false in the sub-render between a keystroke and the debounced sibling fetch —+ // surfacing `showEmptyState` for a query that does have matches. The fix adds an+ // `anyGroupStale` guard mirroring the per-list `remoteResultsAreFresh` gate: the empty+ // state must never show while a contributing group is stale for the current query.+ const groupTypes = [+ TaxonomicFilterGroupType.Events,+ TaxonomicFilterGroupType.EventProperties,+ TaxonomicFilterGroupType.SuggestedFilters,+ ]++ const mountAggregate = (): {+ suggested: ReturnType<typeof infiniteListLogic.build>+ tfl: ReturnType<typeof taxonomicFilterLogic.build>+ } => {+ const tfl = taxonomicFilterLogic({+ taxonomicFilterLogicKey: 'aggregate-freshness',+ taxonomicGroupTypes: groupTypes,+ })+ tfl.mount()+ let suggested: ReturnType<typeof infiniteListLogic.build> | undefined+ for (const gt of groupTypes) {+ const listLogic = infiniteListLogic({+ taxonomicFilterLogicKey: 'aggregate-freshness',+ listGroupType: gt,+ taxonomicGroupTypes: groupTypes,+ showNumericalPropsOnly: false,+ })+ listLogic.mount()+ if (gt === TaxonomicFilterGroupType.SuggestedFilters) {+ suggested = listLogic+ }+ }+ return { suggested: suggested!, tfl }+ }++ it('never shows "No results" while a sibling group is stale for a query that has matches', async () => {+ const { suggested, tfl } = mountAggregate()+ // Let the initial empty-query loads settle so every sibling starts fresh.+ await expectLogic(suggested).toFinishAllListeners()++ // The false-empty condition: the aggregate declaring an empty state in a frame where a+ // contributing group has not yet caught up to the current search query. Watching every+ // store transition (not just settled frames) catches the sub-render flash directly.+ const violations: string[] = []+ const unsubscribe = getContext().store.subscribe(() => {+ if (suggested.values.showEmptyState && suggested.values.searchQuery && tfl.values.anyGroupStale) {+ violations.push(+ `q="${suggested.values.searchQuery}" count=${suggested.values.totalListCount} anyGroupLoading=${tfl.values.anyGroupLoading}`+ )+ }+ })++ // Type "browser" (matches the mock property $browser), extend to a non-matching query,+ // then backspace back to the matching one — each keystroke re-stales the siblings.+ for (const q of ['b', 'br', 'bro', 'brow', 'brows', 'browse', 'browser', 'browserzzz', 'browser']) {+ tfl.actions.setSearchQuery(q)+ }+ await expectLogic(suggested).toFinishAllListeners()+ unsubscribe()++ expect(violations).toEqual([])+ // Sanity: the query that has matches ends up showing them, not an empty state.+ expect(suggested.values.showEmptyState).toBe(false)+ expect(suggested.values.totalResultCount).toBeGreaterThan(0)+ })+ })+describe('internal events local options filtering', () => {// The Internal Events group has multiple local options ("All internal events" plus// product filter options), so substring matching needs to cover both the meta optiondiff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.tsindex a4d71ce41cb7..61ce86f6425b 100644--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts@@ -245,6 +245,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>(['taxonomicGroupTypes','topMatchItemsWithSkeletons','anyGroupLoading',+ 'anyGroupStale','includeStaleEvents',],teamLogic,@@ -676,12 +677,26 @@ export const infiniteListLogic = kea<infiniteListLogicType>([return realResults.length === 0},],+ // True while the aggregated SuggestedFilters ("All") tab is still catching up to the current+ // query. That tab runs no fetch of its own, so it can only tell it has settled by watching its+ // sibling groups: they're either still loading (`anyGroupLoading`) or haven't caught up to the+ // current query yet (`anyGroupStale`, the per-list `remoteResultsAreFresh` guard aggregated).+ // Both `showEmptyState` and `showLoadingState` gate on this to hold "No results" back until the+ // aggregate settles, killing the mid-typing flash.+ suggestedFiltersSettling: [+ (s) => [s.isSuggestedFilters, s.anyGroupLoading, s.anyGroupStale, s.searchQuery],+ (+ isSuggestedFilters: boolean,+ anyGroupLoading: boolean,+ anyGroupStale: boolean,+ searchQuery: string+ ): boolean => isSuggestedFilters && (anyGroupLoading || anyGroupStale) && searchQuery.trim().length > 0,+ ],showEmptyState: [(s) => [s.totalListCount,s.isLoading,- s.isSuggestedFilters,- s.anyGroupLoading,+ s.suggestedFiltersSettling,s.searchQuery,s.hasRemoteDataSource,s.showNonCapturedEventOption,@@ -691,8 +706,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([(totalListCount: number,isLoading: boolean,- isSuggestedFilters: boolean,- anyGroupLoading: boolean,+ suggestedFiltersSettling: boolean,searchQuery: string,hasRemoteDataSource: boolean,showNonCapturedEventOption: boolean,@@ -704,7 +718,9 @@ export const infiniteListLogic = kea<infiniteListLogicType>([// Don't declare "No results" until the fetch for the *current* query has landed —// otherwise a stale/empty list from the previous query masquerades as no matches.remoteResultsAreFresh &&- !(isSuggestedFilters && anyGroupLoading && searchQuery.trim().length > 0) &&+ // Hold "No results" back while the aggregated All tab is still settling (see+ // `suggestedFiltersSettling`).+ !suggestedFiltersSettling &&(!!searchQuery || !hasRemoteDataSource) &&!showNonCapturedEventOption) ||needsMoreSearchCharacters,@@ -712,8 +728,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([showLoadingState: [(s) => [s.isLoading,- s.isSuggestedFilters,- s.anyGroupLoading,+ s.suggestedFiltersSettling,s.results,s.searchQuery,s.hasRemoteDataSource,@@ -721,15 +736,16 @@ export const infiniteListLogic = kea<infiniteListLogicType>([],(isLoading: boolean,- isSuggestedFilters: boolean,- anyGroupLoading: boolean,+ suggestedFiltersSettling: boolean,results: TaxonomicDefinitionTypes[],searchQuery: string,hasRemoteDataSource: boolean,remoteResultsAreFresh: boolean): boolean =>(isLoading ||- (isSuggestedFilters && anyGroupLoading && searchQuery.trim().length > 0) ||+ // Keep the spinner up while the aggregated All tab is still settling (see+ // `suggestedFiltersSettling`).+ suggestedFiltersSettling ||// The current-query remote fetch hasn't landed yet: keep the spinner up rather// than flash a premature "No results". Gated on there being nothing to show// (below) so still-valid rows aren't replaced by a spinner on every keystroke.diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsxindex 2a7fe2f7d6a1..2acd6b7840f2 100644--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx@@ -1786,6 +1786,28 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([],(anyGroupLoading: boolean) => anyGroupLoading,],+ // A group is "stale" when its remote results haven't caught up to the current search+ // query yet (the debounced fetch is pending or in flight). `isLoading` alone is a+ // transient boolean that briefly reads false in the gap between the query changing and+ // the next fetch settling, so the aggregated SuggestedFilters tab — which has no remote+ // fetch of its own and can only gate on its siblings — needs this freshness signal to+ // avoid flashing "No results" before the groups it aggregates have settled. Mirrors the+ // per-list `remoteResultsAreFresh` guard that single tabs already rely on.+ anyGroupStale: [+ (s) => [+ (state, props) => {+ const logics = s.infiniteListLogics(state, props)+ const meta = s.metaGroupTypes(state, props)+ return Object.entries(logics).some(+ ([type, logic]) =>+ !meta.has(type) &&+ logic.isMounted() &&+ !logic.selectors.remoteResultsAreFresh(state, logic.props)+ )+ },+ ],+ (anyGroupStale: boolean) => anyGroupStale,+ ],loadingGroupTypes: [(s) => [(state, props) => {