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.

feat(taxonomic-filter): open picker on All and lead with the contains shortcut (#63402)

Paul D'Ambracf57e603a3f5
diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
index 8544857ada93..62f29c41a14d 100644
--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx
@@ -1176,6 +1176,110 @@ describe('TaxonomicFilter', () => {
})
})
+ it('reopens on the selected category when no Suggested-filters surface is present (control)', async () => {
+ // Guards the activeTab fallback: hosts without a Suggested filters ("All") surface
+ // (control variant, or any picker that doesn't inject it) must still reopen on the
+ // selected item's own category rather than an absent All tab.
+ renderFilter({
+ groupType: TaxonomicFilterGroupType.Events,
+ value: '$pageview',
+ taxonomicGroupTypes: [TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions],
+ })
+
+ await waitFor(() => expect(screen.getByTestId('taxonomic-tab-events')).toBeInTheDocument())
+ expectActiveTab('taxonomic-tab-events', 'taxonomic-tab-actions')
+ })
+
+ // Spec for the insight series picker in the pill variant: searching a term that matches
+ // pageview URLs should make ONE "url contains <query>" shortcut the first row of the
+ // aggregated Suggested filters ("All") tab — ahead of raw URL/event rows. Fails today
+ // because the series (PageviewEvents) group isn't collapsed and the shortcut never leads.
+ describe('series picker: pageview url-contains shortcut leads (pill variant)', () => {
+ let unmountFeatureFlagLogic: (() => void) | null = null
+
+ beforeEach(() => {
+ unmountFeatureFlagLogic = featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TAXONOMIC_FILTER_CATEGORY_DROPDOWN], {
+ [FEATURE_FLAGS.TAXONOMIC_FILTER_CATEGORY_DROPDOWN]: 'pill',
+ })
+ useMocks({
+ get: {
+ '/api/projects/:team/event_definitions': mockGetEventDefinitions,
+ '/api/projects/:team/property_definitions': mockGetPropertyDefinitions,
+ '/api/environments/:team/events/values': [
+ { name: 'https://app.posthog.com/replay' },
+ { name: 'https://app.posthog.com/replay/home' },
+ ],
+ },
+ })
+ })
+
+ afterEach(() => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ unmountFeatureFlagLogic?.()
+ unmountFeatureFlagLogic = null
+ })
+
+ it('reopens on the Data warehouse tab (its own picker), not All, for a data-warehouse selection', async () => {
+ renderFilter({
+ groupType: TaxonomicFilterGroupType.DataWarehouse,
+ value: 'some_table',
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.DataWarehouse,
+ ],
+ })
+
+ // Data warehouse is a config flow (table/column picker) — it should reopen on
+ // its own tab so the user can reconfigure, not drop them on the All surface.
+ const trigger = await screen.findByTestId('taxonomic-category-dropdown-trigger-pill')
+ await waitFor(() => expect(trigger.textContent || '').toMatch(/All|Data warehouse|Events/))
+ expect(trigger).toHaveTextContent('Data warehouse')
+ expect(trigger).not.toHaveTextContent('All')
+ })
+
+ it('opens focused on the All tab, not Events, when an event is already selected', async () => {
+ renderFilter({
+ groupType: TaxonomicFilterGroupType.Events,
+ value: '$pageview',
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.Events,
+ TaxonomicFilterGroupType.Actions,
+ ],
+ })
+
+ // In the pill variant the active category shows in the dropdown trigger; reopening
+ // on an existing event selection should read "All", not "Events".
+ const trigger = await screen.findByTestId('taxonomic-category-dropdown-trigger-pill')
+ // Wait for the dropdown trigger to paint its active-category label before asserting.
+ await waitFor(() => expect(trigger.textContent || '').toMatch(/All|Events|Suggestions/))
+ expect(trigger).toHaveTextContent('All')
+ expect(trigger).not.toHaveTextContent('Events')
+ })
+
+ it('makes the "url contains <query>" shortcut the first Suggested-filters row', async () => {
+ const user = userEvent.setup()
+ renderFilter({
+ taxonomicGroupTypes: [
+ TaxonomicFilterGroupType.SuggestedFilters,
+ TaxonomicFilterGroupType.PageviewEvents,
+ TaxonomicFilterGroupType.EventProperties,
+ ],
+ collapseUrlsToContainsRow: true,
+ })
+
+ const searchInput = await waitFor(() => screen.getByTestId('taxonomic-filter-searchfield'))
+ await user.type(searchInput, 'replay')
+
+ const firstRow = await waitFor(() => screen.getByTestId('prop-filter-suggested_filters-0'))
+ // The leading aggregated row should be the single contains shortcut, not a raw URL.
+ expect(firstRow.textContent || '').toMatch(/contains.*replay|replay.*contains/i)
+ expect(firstRow.textContent || '').not.toContain('https://app.posthog.com/replay')
+ })
+ })
+
describe('category dropdown A/B test', () => {
let unmountFeatureFlagLogic: (() => void) | null = null
diff --git a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
index ec1f6f2f706f..52bebfe742ec 100644
--- a/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/hooks/useTaxonomicFilter.ts
@@ -42,6 +42,7 @@ import {
} from 'lib/components/TaxonomicFilter/types'
import { isQuickFilterItem } from 'lib/components/TaxonomicFilter/types'
import { buildTaxonomicGroups } from 'lib/components/TaxonomicFilter/utils/buildTaxonomicGroups'
+import { isContainsShortcutItem } from 'lib/components/TaxonomicFilter/utils/collapsedContainsRow'
import { MaxContextTaxonomicFilterOption } from 'scenes/max/maxTypes'
import { teamLogic } from 'scenes/teamLogic'
@@ -419,10 +420,13 @@ export function useTaxonomicFilter(opts: UseTaxonomicFilterOptions): TaxonomicFi
(group: TaxonomicFilterGroup, valueIn: TaxonomicFilterValue | null, item: any) => {
// Mirror the legacy `taxonomicFilterLogic.selectItem` recent
// recording so menu commits show up in the dropdown's
- // "Recent" entry. Quick-filter items are skipped (they're
- // shortcuts, not filterable definitions); pinned/recent
- // context wrappers get stripped before persisting.
- if (valueIn != null && item && !isQuickFilterItem(item)) {
+ // "Recent" entry. Quick-filter items and the synthetic
+ // "URL contains <query>" shortcut are skipped (they're
+ // shortcuts, not filterable definitions — and recording the
+ // shortcut would shadow it on the next search, since the recent
+ // shares its entryKey but lacks the contains label/telemetry);
+ // pinned/recent context wrappers get stripped before persisting.
+ if (valueIn != null && item && !isQuickFilterItem(item) && !isContainsShortcutItem(item)) {
const sourceGroupType = hasRecentContext(item) ? item._recentContext.sourceGroupType : group.type
const stripped = hasRecentContext(item) ? stripRecentContext(item) : item
const cleanItem = {
diff --git a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
index 8e5ee253d78c..8c999dbe483b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/infiniteListLogic.ts
@@ -33,6 +33,7 @@ import {
import {
buildUrlContainsShortcut,
COLLAPSED_TO_CONTAINS_ROW,
+ partitionContainsShortcuts,
} from 'lib/components/TaxonomicFilter/utils/collapsedContainsRow'
import { promoteMatchingProperties } from 'lib/components/TaxonomicFilter/utils/promoteProperties'
import { FEATURE_FLAGS } from 'lib/constants'
@@ -738,7 +739,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
if (collapseUrlsToContainsRow && COLLAPSED_TO_CONTAINS_ROW.has(listGroupType)) {
const trimmed = searchQuery.trim()
const hasMatch = trimmed.length > 0 && remoteIsFresh && remoteItems.results.length > 0
- return hasMatch ? [buildUrlContainsShortcut(trimmed)] : []
+ return hasMatch ? [buildUrlContainsShortcut(trimmed, listGroupType)] : []
}
const results = hasRemoteDataSource ? (remoteIsFresh ? remoteItems.results : []) : localItems.results
const realMatches = promoteMatchingProperties(results, searchQuery).slice(0, MAX_TOP_MATCHES_PER_GROUP)
@@ -898,7 +899,7 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
// stale match from the previous query producing a shortcut for the new one.
const remoteIsFresh = (remoteItems.searchQuery ?? '').trim() === trimmed
const hasMatch = trimmed.length > 0 && remoteIsFresh && remoteItems.results.length > 0
- const results = hasMatch ? [buildUrlContainsShortcut(trimmed)] : []
+ const results = hasMatch ? [buildUrlContainsShortcut(trimmed, listGroupType)] : []
return {
results,
count: results.length,
@@ -928,8 +929,16 @@ export const infiniteListLogic = kea<infiniteListLogicType>([
...remoteItems.results,
...topMatches,
]
+ const orderedBase = searchQuery
+ ? promoteMatchingProperties(combinedResults, searchQuery)
+ : combinedResults
+ // The "URL contains <query>" shortcut leads the aggregated SuggestedFilters list —
+ // ahead of recents/pinned/top-matches — so a URL search surfaces the contains
+ // suggestion first. Everything else keeps its existing order.
+ const [shortcutItems, otherItems] = partitionContainsShortcuts(orderedBase, (item) => item)
+ const orderedResults = shortcutItems.length ? [...shortcutItems, ...otherItems] : orderedBase
return {
- results: searchQuery ? promoteMatchingProperties(combinedResults, searchQuery) : combinedResults,
+ results: orderedResults,
count:
keywordShortcutItems.length +
recentPrefix.length +
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
index de7b0b631e60..4c7396daa4a8 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.test.tsx
@@ -606,6 +606,116 @@ describe('MenuFilterCombobox', () => {
})
})
+ // Spec for the insight series picker (e.g. funnel steps include Pageview events):
+ // opening the menu shows "All" with event-context recents/pinned; searching a term
+ // that matches pageview URLs surfaces ONE "url contains <query>" shortcut as the very
+ // first row — ahead of recents, pinned, and event rows. These fail today because the
+ // series (PageviewEvents) group is not collapsed and the shortcut never leads the list.
+ describe('pageview url-contains shortcut leads the series picker All surface', () => {
+ const mockUrlValues = (urls: string[]): void => {
+ apiGet.mockImplementation((url: string) => {
+ if (url.includes('events/values') && url.includes('current_url')) {
+ return Promise.resolve(urls.map((name) => ({ name })))
+ }
+ return Promise.resolve({ results: [], count: 0 })
+ })
+ }
+
+ it('defaults to the All scope with event-context recents and pinned shown', async () => {
+ mockUrlValues([])
+ renderAll({
+ groupTypes: [TaxonomicFilterGroupType.PageviewEvents, TaxonomicFilterGroupType.Events],
+ recentEntries: [makeEntry(TaxonomicFilterGroupType.Events, 'recent_signup', 'Events')],
+ pinnedEntries: [makeEntry(TaxonomicFilterGroupType.Events, 'pinned_purchase', 'Events')],
+ })
+
+ await waitFor(() => expect(rowTexts().some((t) => t.includes('recent_signup'))).toBe(true))
+ expect(rowTexts().some((t) => t.includes('pinned_purchase'))).toBe(true)
+ expect(screen.getByRole('combobox', { name: 'Filter category' })).toHaveTextContent('All')
+ })
+
+ it('opens focused on All, not the selected item category, when an event is already selected', async () => {
+ apiGet.mockResolvedValue({ results: [], count: 0 })
+ // Reopening the series picker on an existing `$pageview` selection: the menu
+ // should land on the "All" scope, not jump to the Events category.
+ const selectedEntry = makeEntry(TaxonomicFilterGroupType.Events, '$pageview', 'Events')
+ render(
+ <Provider>
+ <TaxonomicFilterHeadless.Root
+ taxonomicGroupTypes={[TaxonomicFilterGroupType.Events, TaxonomicFilterGroupType.Actions]}
+ onChange={jest.fn()}
+ >
+ <MenuFilterCombobox
+ drillTo="all"
+ selectedEntry={selectedEntry}
+ onCommit={jest.fn()}
+ onBack={jest.fn()}
+ />
+ </TaxonomicFilterHeadless.Root>
+ </Provider>
+ )
+
+ const category = await screen.findByRole('combobox', { name: 'Filter category' })
+ // Wait for the Select to paint its active-category label before asserting.
+ await waitFor(() => expect(category.textContent || '').toMatch(/All|Events/))
+ expect(category).toHaveTextContent('All')
+ expect(category).not.toHaveTextContent('Events')
+ })
+
+ it('leads with the committed selection as the first row when idle (no search)', async () => {
+ apiGet.mockResolvedValue({ results: [{ id: 1, name: 'autocapture' }], count: 1 })
+ // Reopening on an existing selection: the user often just wants to check what's
+ // chosen, so the committed value is the first row even ahead of recents.
+ const selectedEntry = makeEntry(TaxonomicFilterGroupType.Events, 'my_current_event', 'Events')
+ render(
+ <Provider>
+ <TaxonomicFilterHeadless.Root
+ taxonomicGroupTypes={[TaxonomicFilterGroupType.Events]}
+ onChange={jest.fn()}
+ >
+ <MenuFilterCombobox
+ drillTo="all"
+ selectedEntry={selectedEntry}
+ recentEntries={[makeEntry(TaxonomicFilterGroupType.Events, 'recent_event', 'Events')]}
+ onCommit={jest.fn()}
+ onBack={jest.fn()}
+ />
+ </TaxonomicFilterHeadless.Root>
+ </Provider>
+ )
+
+ await waitFor(() => expect(rowTexts().some((t) => t.includes('my_current_event'))).toBe(true))
+ expect(rowTexts()[0]).toContain('my_current_event')
+ })
+
+ it('puts the "url contains <query>" shortcut first, then recent, then pinned', async () => {
+ mockUrlValues(['https://app.posthog.com/replay', 'https://app.posthog.com/replay/home'])
+ renderAll({
+ groupTypes: [TaxonomicFilterGroupType.PageviewEvents, TaxonomicFilterGroupType.Events],
+ recentEntries: [makeEntry(TaxonomicFilterGroupType.Events, 'replay_recent', 'Events')],
+ pinnedEntries: [makeEntry(TaxonomicFilterGroupType.Events, 'replay_pinned', 'Events')],
+ searchQuery: 'replay',
+ })
+
+ // Wait on a stable post-search signal (a matching recent) so the ordering
+ // assertions fail fast rather than timing out waiting for a row that never renders.
+ await waitFor(() => expect(rowTexts().some((t) => t.includes('replay_recent'))).toBe(true))
+ const rows = rowTexts()
+ const shortcutIdx = rows.findIndex((t) => /contains/i.test(t) && /replay/i.test(t))
+ const recentIdx = rows.findIndex((t) => t.includes('replay_recent'))
+ const pinnedIdx = rows.findIndex((t) => t.includes('replay_pinned'))
+
+ // The contains shortcut leads the whole list, ahead of recents/pinned/events.
+ expect(shortcutIdx).toBe(0)
+ // Assert both rows are actually present (findIndex returns -1 when absent) so a
+ // regression that drops the recent/pinned row fails loudly, not on index arithmetic.
+ expect(recentIdx).toBeGreaterThan(0)
+ expect(pinnedIdx).toBeGreaterThan(recentIdx)
+ // and the raw matched URLs are collapsed away into the single shortcut.
+ expect(rows.some((t) => t.includes('https://app.posthog.com/replay'))).toBe(false)
+ })
+ })
+
it('drops the recents/pinned prefix once the query no longer matches them', async () => {
apiGet.mockResolvedValue({ results: [{ id: 1, name: 'autocapture' }], count: 1 })
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
index e590d39b9202..d1bf5f80bfd0 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
@@ -43,8 +43,17 @@ import { getCoreFilterDefinition } from '~/taxonomy/helpers'
import { useTaxonomicFilterContext } from '../headless/context'
import { useGroupList } from '../hooks/useGroupList'
-import { TaxonomicDefinitionTypes, TaxonomicFilterGroup, TaxonomicFilterGroupType } from '../types'
-import { COLLAPSED_TO_CONTAINS_ROW, urlContainsRowLabel } from '../utils/collapsedContainsRow'
+import {
+ OPEN_AS_SELF_ON_REOPEN,
+ TaxonomicDefinitionTypes,
+ TaxonomicFilterGroup,
+ TaxonomicFilterGroupType,
+} from '../types'
+import {
+ COLLAPSED_TO_CONTAINS_ROW,
+ partitionContainsShortcuts,
+ urlContainsRowLabel,
+} from '../utils/collapsedContainsRow'
import { promoteMatchingBy } from '../utils/promoteProperties'
import { MenuFilterHeader } from './Header'
import { PreviewPane } from './PreviewPane'
@@ -143,6 +152,15 @@ function entryMatchesSelection(entry: MenuFilterEntry, selected: MenuFilterEntry
return entryValueMatchesSelection(entry, selected) || entryLabelMatchesSelection(entry, selected)
}
+/** Move the element at `index` to the front, preserving the order of the rest.
+ * No-op when `index <= 0` (already first, or not found via `findIndex` -> -1). */
+function floatToFront<T>(list: T[], index: number): T[] {
+ if (index <= 0) {
+ return list
+ }
+ return [list[index], ...list.slice(0, index), ...list.slice(index + 1)]
+}
+
function fuseMatchEntries(entries: MenuFilterEntry[], query: string): MenuFilterEntry[] {
if (entries.length === 0) {
return []
@@ -196,19 +214,17 @@ export function MenuFilterCombobox({
// `searchQuery` from the orchestrator's `getGroupListInput`, not from
// us. Keeping a local mirror just for the controlled input ergonomics.
const { groups, searchQuery, setSearchQuery } = useTaxonomicFilterContext()
- // When opening with chips visible (`drillTo='all'`) and a current
- // selection exists, start on the matching chip so the user lands on
- // their selection's category by default — they can still tab back to
- // "All" or any other chip without leaving the combobox.
- const [activeChip, setActiveChip] = useState<DrillCategory>(() => {
- // Collapsed groups (e.g. Pageview URLs) aren't navigable categories, so a
- // selection from one lands on "All" — its row still surfaces there via the
- // selected-entry prepend — instead of stranding the user in a hidden scope.
- if (drillTo === 'all' && selectedEntry && !COLLAPSED_TO_CONTAINS_ROW.has(selectedEntry.group.type)) {
- return selectedEntry.group.type
- }
- return drillTo
- })
+ // Open on the drill scope ("All" for the default surface). Reopening with a committed
+ // selection used to jump to that item's category; we now lead with "All" so the user
+ // lands on recents/pinned + a cross-category search (the selection still surfaces via
+ // the selected-entry prepend). The exception is config/edit flows (data-warehouse
+ // columns reach the combobox as DataWarehouseProperties) — they reopen on their own
+ // chip so the user can reconfigure, mirroring the legacy `activeTab`.
+ const [activeChip, setActiveChip] = useState<DrillCategory>(() =>
+ drillTo === 'all' && selectedEntry && OPEN_AS_SELF_ON_REOPEN.has(selectedEntry.group.type)
+ ? selectedEntry.group.type
+ : drillTo
+ )
// The scope the user is actually looking at: the active chip when chips show
// (drillTo='all'), otherwise the drilled-to category. Single source for the
// telemetry group type, empty state, stale-toggle gating, and reset trigger.
@@ -343,9 +359,13 @@ export function MenuFilterCombobox({
if (trimmedQuery && items.length > 0) {
const label = urlContainsRowLabel(trimmedQuery)
merged.push({
- // `isContainsShortcut` tags this synthetic row so the commit
- // telemetry can measure adoption of the contains shortcut vs
- // the old per-URL value-picker.
+ // A plain item (not a QuickFilterItem): the commit reads its value via
+ // `group.getValue` (the query) and the group `type` drives the host's
+ // expansion — PageviewUrls -> `$current_url IContains`, PageviewEvents ->
+ // a `$pageview` event with that filter (ActionFilterRow's group-type
+ // branch). The legacy list reaches the same filter via the QuickFilterItem
+ // `eventName` path instead — see `buildUrlContainsShortcut`.
+ // `isContainsShortcut` tags it for commit telemetry + the lead-first ordering.
item: { name: trimmedQuery, isContainsShortcut: true } as unknown as TaxonomicDefinitionTypes,
group,
name: label,
@@ -522,29 +542,42 @@ export function MenuFilterCombobox({
: null
base = indexed.filter((e) => !!e.group.endpoint || (localMatches?.has(e) ?? false))
}
+ const scope = showChips ? activeChip : drillTo
// Promote the committed selection to index 0 so base-ui's
- // `autoHighlight="always"` lands on it the moment the list
- // mounts — keyboard nav starts on the selected row, the
- // preview pane shows the right definition, and `Enter` re-commits
- // without forcing the user to scroll. Skip when the user has
- // typed a search query — relevance order should win there.
- if (!q && selectedRowId) {
- const idx = base.findIndex((e) => rowDomId(e) === selectedRowId)
- if (idx > 0) {
- base = [base[idx], ...base.slice(0, idx), ...base.slice(idx + 1)]
- }
+ // `autoHighlight="always"` lands on it the moment the list mounts — keyboard nav
+ // starts on the selected row, the preview shows the right definition, and `Enter`
+ // re-commits without scrolling. Skip while searching (relevance wins). The All scope
+ // re-floats after its recents/pinned assembly below, so only do it here for drilled scopes.
+ if (!q && selectedRowId && scope !== 'all') {
+ base = floatToFront(
+ base,
+ base.findIndex((e) => rowDomId(e) === selectedRowId)
+ )
}
// Default "All" surface leads with recents/pinned (fixed order), then
// the cross-tab content with `email`/`url` promotion. Recents/pinned
// stay above the content rows so users can learn the order.
- const scope = showChips ? activeChip : drillTo
if (scope === 'all') {
const prefixKeys = new Set(recentsPinnedPrefix.map(entryKey))
const content = prefixKeys.size > 0 ? base.filter((e) => !prefixKeys.has(entryKey(e))) : base
- return [
+ // The "URL contains <query>" shortcut leads the whole list — ahead of
+ // recents/pinned/content — because a URL search almost always means the user
+ // wants the contains match. Everything else keeps the recents-then-pinned order.
+ const [shortcuts, rest] = partitionContainsShortcuts(content, (e) => e.item)
+ const assembled = [
+ ...shortcuts,
...recentsPinnedPrefix,
- ...promoteMatchingBy(content, searchQuery, (e) => (e.item as { name?: string }).name ?? e.name),
+ ...promoteMatchingBy(rest, searchQuery, (e) => (e.item as { name?: string }).name ?? e.name),
]
+ // Idle (no search): float the committed selection to the very first row so the
+ // user can see/verify what's currently chosen without leaving the All surface.
+ if (!q && selectedRowId) {
+ return floatToFront(
+ assembled,
+ assembled.findIndex((e) => rowDomId(e) === selectedRowId)
+ )
+ }
+ return assembled
}
return base
}, [indexed, searchQuery, selectedRowId, recentsPinnedPrefix, showChips, activeChip, drillTo])
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
index c92bba2ac10e..c68f2d9720d7 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
@@ -291,10 +291,10 @@ export function TaxonomicFilterMenu({
// dwh-pick list they never visited.
return { kind: 'dwh-config', table: selected.item, group: selected.group, origin: 'menu' }
}
- // Land on the regular combobox with chips visible — the matching
- // chip auto-selects via `selectedEntry` inside the combobox so the
- // user keeps full context and can switch categories without
- // bouncing back to the dropdown menu.
+ // Land on the regular combobox on the "All" scope. The committed selection
+ // floats to the first row (and stays highlighted) so the user can verify it
+ // at a glance, while still seeing recents/pinned and being able to search
+ // across every category.
return { kind: 'combobox', drillTo: 'all' }
}, [selected])
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 46110add2802..1c114dfd48a0 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -38,6 +38,7 @@ import {
ListStorage,
QuickFilterItem,
META_GROUP_TYPES,
+ OPEN_AS_SELF_ON_REOPEN,
SelectedProperties,
SimpleOption,
SkeletonItem,
@@ -1659,14 +1660,25 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
if (explicitActiveTab && groupTypes.includes(explicitActiveTab)) {
return explicitActiveTab
}
- // If there's an existing filter type (e.g., SQL expression being edited),
- // use that instead of defaulting to SuggestedFilters
- if (propsGroupType && groupTypes.includes(propsGroupType)) {
+ // Config/edit flows have no simple category "value" to verify on the All
+ // surface — reopen them on their own tab: a SQL/HogQL expression lands in its
+ // editor, a data-warehouse selection in its table/column picker.
+ if (
+ propsGroupType &&
+ OPEN_AS_SELF_ON_REOPEN.has(propsGroupType) &&
+ groupTypes.includes(propsGroupType)
+ ) {
return propsGroupType
}
+ // Otherwise lead with the All (Suggested filters) surface so reopening on an
+ // existing selection still shows recents/pinned + a cross-category search,
+ // rather than jumping to the selected item's category.
if (groupTypes.includes(TaxonomicFilterGroupType.SuggestedFilters)) {
return TaxonomicFilterGroupType.SuggestedFilters
}
+ if (propsGroupType && groupTypes.includes(propsGroupType)) {
+ return propsGroupType
+ }
return groupTypes.find((t) => !metaGroupTypes.has(t)) ?? groupTypes[0]
},
],
diff --git a/frontend/src/lib/components/TaxonomicFilter/types.ts b/frontend/src/lib/components/TaxonomicFilter/types.ts
index a6959d937792..e31e8c9bb518 100644
--- a/frontend/src/lib/components/TaxonomicFilter/types.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/types.ts
@@ -356,6 +356,16 @@ export const META_GROUP_TYPES = new Set<TaxonomicFilterGroupType>([
TaxonomicFilterGroupType.MaxAIContext,
])
+/** Selection types that reopen on their own tab/panel rather than the default "All" surface,
+ * because they're config/edit flows (an expression editor, a data-warehouse table/column
+ * picker) with no simple category value to verify at a glance. Honored by the legacy
+ * `activeTab` selector and the rebuild menu's `activeChip` initializer alike. */
+export const OPEN_AS_SELF_ON_REOPEN = new Set<TaxonomicFilterGroupType>([
+ TaxonomicFilterGroupType.HogQLExpression,
+ TaxonomicFilterGroupType.DataWarehouse,
+ TaxonomicFilterGroupType.DataWarehouseProperties,
+])
+
export interface InfiniteListLogicProps extends TaxonomicFilterLogicProps {
listGroupType: TaxonomicFilterGroupType
}
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/collapsedContainsRow.ts b/frontend/src/lib/components/TaxonomicFilter/utils/collapsedContainsRow.ts
index 1292a3aa9b8e..c48c68bc2162 100644
--- a/frontend/src/lib/components/TaxonomicFilter/utils/collapsedContainsRow.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/collapsedContainsRow.ts
@@ -7,9 +7,14 @@ import { QuickFilterItem, TaxonomicFilterGroupType } from '../types'
* People filtering by URL overwhelmingly want a contains match, so one synthetic
* row (when any URL matches) beats a wall of exact URLs. Shared by the legacy
* picker (`infiniteListLogic`) and the rebuild menu (`menu/Combobox`) so both arms
- * of the experiment collapse identically. */
+ * of the experiment collapse identically.
+ *
+ * - `PageviewUrls` is the property-filter flavour ($current_url IContains <query>).
+ * - `PageviewEvents` is the series flavour: a `$pageview` event filtered by the same
+ * `$current_url IContains <query>`. Both hit the same URL-values endpoint. */
export const COLLAPSED_TO_CONTAINS_ROW: ReadonlySet<TaxonomicFilterGroupType> = new Set([
TaxonomicFilterGroupType.PageviewUrls,
+ TaxonomicFilterGroupType.PageviewEvents,
])
export function urlContainsRowLabel(query: string): string {
@@ -18,9 +23,18 @@ export function urlContainsRowLabel(query: string): string {
/** Synthetic row committed as `$current_url IContains <query>`. Returned as a
* `QuickFilterItem` so it flows through the existing `isQuickFilterItem` handling
- * in the property- and universal-filter hosts, committing the same filter the
- * per-URL value picker used to — without listing every matching URL. */
-export function buildUrlContainsShortcut(query: string): QuickFilterItem {
+ * in the property-, universal-, and series (ActionFilterRow) hosts, committing the
+ * same filter the per-URL value picker used to — without listing every matching URL.
+ *
+ * For the `PageviewEvents` (series) group the shortcut also carries `eventName:
+ * '$pageview'`. How that's consumed differs by host, all reaching the same filter:
+ * - series host (`ActionFilterRow`) expands it into a `$pageview` event + the
+ * `$current_url IContains` property filter (reads `eventName`);
+ * - property/universal hosts intentionally ignore `eventName` (a property filter
+ * can't sprout an event) and commit the bare `$current_url IContains` filter;
+ * - the rebuild menu commits PageviewEvents via the group `type`, not `eventName`
+ * (its synthetic row is a plain item, not this QuickFilterItem). */
+export function buildUrlContainsShortcut(query: string, groupType?: TaxonomicFilterGroupType): QuickFilterItem {
return {
_type: 'quick_filter',
name: urlContainsRowLabel(query),
@@ -29,5 +43,27 @@ export function buildUrlContainsShortcut(query: string): QuickFilterItem {
propertyKey: '$current_url',
propertyFilterType: PropertyFilterType.Event,
isContainsShortcut: true,
+ ...(groupType === TaxonomicFilterGroupType.PageviewEvents ? { eventName: '$pageview' } : {}),
}
}
+
+/** A row that is the synthetic "URL contains <query>" shortcut. Deliberately checks the
+ * tag directly rather than via `isQuickFilterItem`, because the rebuild menu's shortcut
+ * is a plain item (not a QuickFilterItem) while the legacy list's is a QuickFilterItem —
+ * both carry `isContainsShortcut`. */
+export function isContainsShortcutItem(item: unknown): boolean {
+ return !!item && typeof item === 'object' && (item as { isContainsShortcut?: boolean }).isContainsShortcut === true
+}
+
+/** Split a list so the synthetic "URL contains <query>" shortcut(s) come first.
+ * `getItem` maps a list element to its underlying definition item — the rebuild wraps it
+ * in a `{ item }` entry, the legacy list holds the item directly. Returns `[shortcuts, rest]`
+ * so callers can either lead with the shortcut or splice other rows (recents/pinned) between. */
+export function partitionContainsShortcuts<T>(list: T[], getItem: (entry: T) => unknown): [T[], T[]] {
+ const shortcuts: T[] = []
+ const rest: T[] = []
+ for (const entry of list) {
+ ;(isContainsShortcutItem(getItem(entry)) ? shortcuts : rest).push(entry)
+ }
+ return [shortcuts, rest]
+}