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): replay-style input trigger for the rebuild menu (#63420)

Paul D'Ambra42c3988189f2
diff --git a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
index 2e53b27d0ab7..2244ae74a0c0 100644
--- a/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
+++ b/frontend/src/lib/components/PropertyFilters/PropertyFilters.tsx
@@ -59,6 +59,12 @@ export interface PropertyFiltersProps {
addFilterDocLink?: string
operatorAllowlist?: OperatorValueSelectProps['operatorAllowlist']
hogQLGlobals?: Record<string, any>
+ /**
+ * `'input'` renders the replay-style input-box add-filter trigger; `'button'`
+ * (the default) renders a button. Only has an effect on the rebuild menu
+ * (`TAXONOMIC_FILTER_MENU_REBUILD`).
+ */
+ triggerVariant?: 'button' | 'input'
}
export function PropertyFilters({
@@ -97,6 +103,7 @@ export function PropertyFilters({
addFilterDocLink,
operatorAllowlist,
hogQLGlobals,
+ triggerVariant = 'button',
}: PropertyFiltersProps): JSX.Element {
const logicProps = { propertyFilters, onChange, pageKey, sendAllKeyUpdates }
const { filters, filtersWithNew, filterIds, filterIdsWithNew } = useValues(propertyFilterLogic(logicProps))
@@ -167,6 +174,7 @@ export function PropertyFilters({
editable={editable}
operatorAllowlist={operatorAllowlist}
hogQLGlobals={hogQLGlobals}
+ triggerVariant={triggerVariant}
/>
)}
errorMessage={errorMessages && errorMessages[index]}
diff --git a/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.triggerVariant.test.tsx b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.triggerVariant.test.tsx
new file mode 100644
index 000000000000..14173e289385
--- /dev/null
+++ b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.triggerVariant.test.tsx
@@ -0,0 +1,97 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen, waitFor } from '@testing-library/react'
+import { Provider } from 'kea'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+
+import { useMocks } from '~/mocks/jest'
+import { actionsModel } from '~/models/actionsModel'
+import { groupsModel } from '~/models/groupsModel'
+import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'
+import { initKeaTests } from '~/test/init'
+import { mockGetEventDefinitions, mockGetPropertyDefinitions } from '~/test/mocks'
+
+import { TaxonomicFilterGroupType } from '../../TaxonomicFilter/types'
+import { PropertyFilters } from '../PropertyFilters'
+
+jest.mock('lib/components/AutoSizer', () => ({
+ AutoSizer: ({ renderProp }: { renderProp: (size: { height: number; width: number }) => React.ReactNode }) =>
+ renderProp({ height: 400, width: 400 }),
+}))
+
+describe('TaxonomicPropertyFilter triggerVariant (rebuild menu)', () => {
+ let unmountFeatureFlagLogic: (() => void) | null = null
+
+ beforeEach(() => {
+ initKeaTests()
+ actionsModel.mount()
+ groupsModel.mount()
+ propertyDefinitionsModel.mount()
+ localStorage.clear()
+ useMocks({
+ get: {
+ '/api/projects/:team/event_definitions': mockGetEventDefinitions,
+ '/api/projects/:team/property_definitions': mockGetPropertyDefinitions,
+ '/api/projects/:team/actions': { results: [] },
+ },
+ post: {
+ '/api/environments/:team/query': { results: [] },
+ },
+ })
+ unmountFeatureFlagLogic = featureFlagLogic.mount()
+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TAXONOMIC_FILTER_MENU_REBUILD], {
+ [FEATURE_FLAGS.TAXONOMIC_FILTER_MENU_REBUILD]: true,
+ })
+ })
+
+ afterEach(() => {
+ featureFlagLogic.actions.setFeatureFlags([], {})
+ unmountFeatureFlagLogic?.()
+ unmountFeatureFlagLogic = null
+ cleanup()
+ })
+
+ function renderWith(triggerVariant?: 'button' | 'input'): void {
+ render(
+ <Provider>
+ <PropertyFilters
+ pageKey="input-trigger-test"
+ propertyFilters={[]}
+ onChange={jest.fn()}
+ disablePopover
+ taxonomicGroupTypes={[TaxonomicFilterGroupType.EventProperties]}
+ triggerVariant={triggerVariant}
+ />
+ </Provider>
+ )
+ }
+
+ it.each([
+ { name: 'renders the button trigger by default', triggerVariant: undefined, expectInput: false },
+ {
+ name: 'renders the button trigger for triggerVariant="button"',
+ triggerVariant: 'button',
+ expectInput: false,
+ },
+ {
+ name: 'renders the input-box trigger for triggerVariant="input"',
+ triggerVariant: 'input',
+ expectInput: true,
+ },
+ ] as const)('$name', async ({ triggerVariant, expectInput }) => {
+ renderWith(triggerVariant)
+
+ if (expectInput) {
+ await waitFor(() => {
+ expect(screen.getByTestId('taxonomic-filter-menu-input')).toBeInTheDocument()
+ })
+ } else {
+ await waitFor(() => {
+ expect(screen.getByTestId('taxonomic-popover-menu-trigger')).toBeInTheDocument()
+ })
+ expect(screen.queryByTestId('taxonomic-filter-menu-input')).not.toBeInTheDocument()
+ }
+ })
+})
diff --git a/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
index 569b2ec1ee68..09945bb8e2a7 100644
--- a/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
+++ b/frontend/src/lib/components/PropertyFilters/components/TaxonomicPropertyFilter.tsx
@@ -87,6 +87,7 @@ export function TaxonomicPropertyFilter({
operatorAllowlist,
endpointFilters,
hogQLGlobals,
+ triggerVariant = 'button',
}: PropertyFilterInternalProps): JSX.Element {
const pageKey = useMemo(() => pageKeyInput || `filter-${uniqueMemoizedIndex++}`, [pageKeyInput])
const baseGroupTypes = taxonomicGroupTypes || DEFAULT_TAXONOMIC_GROUP_TYPES
@@ -325,11 +326,13 @@ export function TaxonomicPropertyFilter({
endpointFilters={endpointFilters}
hogQLGlobals={hogQLGlobals}
enableKeywordShortcuts
+ triggerVariant={triggerVariant}
triggerButtonProps={{
type: 'secondary',
size,
truncate: true,
sideIcon: null,
+ fullWidth: triggerVariant === 'input',
icon: !valuePresent ? <IconPlusSmall /> : undefined,
}}
/>
diff --git a/frontend/src/lib/components/PropertyFilters/types.ts b/frontend/src/lib/components/PropertyFilters/types.ts
index 94f40588e591..bd48e2d383ac 100644
--- a/frontend/src/lib/components/PropertyFilters/types.ts
+++ b/frontend/src/lib/components/PropertyFilters/types.ts
@@ -68,4 +68,10 @@ export interface PropertyFilterInternalProps {
addFilterDocLink?: string
endpointFilters?: Record<string, any>
hogQLGlobals?: Record<string, any>
+ /**
+ * `'input'` renders the replay-style input-box add-filter trigger; `'button'`
+ * (the default) renders a button. Only has an effect on the rebuild menu
+ * (`TAXONOMIC_FILTER_MENU_REBUILD`).
+ */
+ triggerVariant?: 'button' | 'input'
}
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
index 82bc4bfca63a..28660096571a 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/Combobox.tsx
@@ -13,7 +13,7 @@
import { Autocomplete } from '@base-ui/react/autocomplete'
import { useValues } from 'kea'
import posthog from 'posthog-js'
-import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import { MutableRefObject, ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { IconCheck, IconChevronRight, IconClock, IconPinFilled } from '@posthog/icons'
import {
@@ -35,6 +35,7 @@ import {
Skeleton,
} from '@posthog/quill'
+import { LemonInput } from 'lib/lemon-ui/LemonInput'
import { createFuse } from 'lib/utils/fuseSearch'
import { surveyQuestionLabelsLogic } from 'scenes/surveys/surveyQuestionLabelsLogic'
@@ -135,6 +136,15 @@ export interface MenuFilterComboboxProps {
title?: string
/** Currently-committed selection — rendered with a checkmark + scrolled into view. */
selectedEntry?: MenuFilterEntry | null
+ /** Shared ref to the search input so the popover can target it for focus.
+ * Mutable because the adapter assigns the input element onto it. */
+ inputRef?: MutableRefObject<HTMLInputElement | null>
+ /**
+ * Filter-icon menu button shown as the field's prefix in input-trigger
+ * mode (where the field is a `LemonInput` in the trigger row). Omitted in
+ * the popover/button mode, which renders the field as a quill input.
+ */
+ iconButton?: ReactElement
}
export function MenuFilterCombobox({
@@ -147,6 +157,8 @@ export function MenuFilterCombobox({
onBack,
title,
selectedEntry,
+ inputRef: externalInputRef,
+ iconButton,
}: MenuFilterComboboxProps): JSX.Element {
// Sync our local query to the orchestrator's so remote-endpoint groups
// (Pageview URLs, Screens, etc.) actually fetch — `useGroupList` reads
@@ -192,7 +204,8 @@ export function MenuFilterCombobox({
// `filtered` (selected entry promoted to index 0) keeps the
// highlight on the same row.
const [highlightedEntry, setHighlightedEntry] = useState<MenuFilterEntry | null>(selectedEntry ?? null)
- const inputRef = useRef<HTMLInputElement | null>(null)
+ const localInputRef = useRef<HTMLInputElement | null>(null)
+ const inputRef = externalInputRef ?? localInputRef
// Stale events (event definitions not ingested within the staleness window)
// are hidden by default to match the legacy picker. The opt-in is per-search:
@@ -791,6 +804,99 @@ export function MenuFilterCombobox({
}
}
+ // Category dropdown — picks the active scope; replaces the old flex-wrapped
+ // chip row. Only shown when there's more than the implicit "All" category.
+ const categorySelect =
+ showChips && categoryOptions.length > 1 ? (
+ <Select<DrillCategory>
+ value={activeChip}
+ onValueChange={(value) => {
+ posthog.capture('taxonomic filter menu category changed', {
+ fromChip: activeChip,
+ toChip: value ?? 'all',
+ via: 'dropdown',
+ })
+ setActiveChip(value ?? 'all')
+ inputRef.current?.focus()
+ }}
+ itemToStringLabel={(value) => categoryOptions.find((o) => o.value === value)?.label ?? 'All'}
+ >
+ <SelectTrigger
+ size="sm"
+ aria-label="Filter category"
+ data-attr="menu-filter-category"
+ className="mr-0.5"
+ >
+ <SelectValue />
+ </SelectTrigger>
+ {/* Fit the list to its items: at least as wide as the trigger,
+ grow to the longest option, capped at the available viewport
+ width so it never overflows. */}
+ <SelectContent
+ align="end"
+ alignItemWithTrigger={false}
+ className="w-max min-w-(--anchor-width) max-w-(--available-width)"
+ >
+ <SelectGroup>
+ {categoryOptions.map((o) => (
+ <SelectItem key={o.value} value={o.value}>
+ {o.label}
+ </SelectItem>
+ ))}
+ </SelectGroup>
+ </SelectContent>
+ </Select>
+ ) : null
+
+ // The search field — a full-width row between the header and the
+ // list/preview, so the menu chrome wraps it (header above, results below).
+ // In input-trigger mode it's a LemonInput matching the surrounding scene's
+ // UI, with base-ui driving the inner input via `render`, the filter-icon
+ // button as its prefix and the category dropdown as its suffix. The button
+ // trigger keeps the quill input bar.
+ const searchField = iconButton ? (
+ <AutocompleteLemonInput
+ value={searchQuery}
+ onValueChange={setSearchQuery}
+ sharedInputRef={inputRef}
+ prefix={iconButton}
+ suffix={categorySelect ?? undefined}
+ placeholder={activePlaceholder}
+ data-attr="menu-filter-search"
+ onKeyDown={handleInputKeyDown}
+ onPaste={(e) => {
+ pastedCharsRef.current += e.clipboardData.getData('text').length
+ }}
+ />
+ ) : (
+ <>
+ <Autocomplete.Input
+ render={
+ <InputGroupInput
+ ref={inputRef}
+ autoFocus
+ data-attr="menu-filter-search"
+ placeholder={activePlaceholder}
+ onKeyDown={handleInputKeyDown}
+ onPaste={(e: React.ClipboardEvent<HTMLInputElement>) => {
+ pastedCharsRef.current += e.clipboardData.getData('text').length
+ }}
+ />
+ }
+ value={searchQuery}
+ onChange={(e) => setSearchQuery(e.target.value)}
+ />
+ {categorySelect && <InputGroupAddon align="inline-end">{categorySelect}</InputGroupAddon>}
+ </>
+ )
+
+ // Full-width input row, sitting between the header and the list/preview
+ // columns. The LemonInput (input-trigger) is full width on its own; the
+ // quill input needs the InputGroup wrapper.
+ const searchFieldRow = (
+ <div className="p-2 border-b">{iconButton ? searchField : <InputGroup>{searchField}</InputGroup>}</div>
+ )
+
return (
<div className="flex flex-col flex-1 min-h-0">
<MenuFilterHeader
@@ -816,80 +922,12 @@ export function MenuFilterCombobox({
itemToStringValue={(entry: MenuFilterEntry) => entry.name}
onItemHighlighted={(entry) => setHighlightedEntry((entry as MenuFilterEntry | undefined) ?? null)}
>
+ {searchFieldRow}
{/* Flex layout: list flexes, separator is 1px, preview is a
fixed 300px column. `shrink-0` on the preview keeps it
stable when the popover (or list contents) change width. */}
<div className="flex flex-1 min-h-0">
<div className="flex flex-col flex-1 min-w-0 min-h-0">
- <div className="p-2 border-b">
- <InputGroup>
- <Autocomplete.Input
- render={
- <InputGroupInput
- ref={inputRef}
- autoFocus
- data-attr="menu-filter-search"
- placeholder={activePlaceholder}
- onKeyDown={handleInputKeyDown}
- onPaste={(e: React.ClipboardEvent<HTMLInputElement>) => {
- pastedCharsRef.current += e.clipboardData.getData('text').length
- }}
- />
- }
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- />
- {/* Category dropdown — trailing addon. Picks
- the active scope; replaces the old
- flex-wrapped chip row. Only shown when
- there's more than the implicit "All"
- category to choose between. */}
- {showChips && categoryOptions.length > 1 && (
- <InputGroupAddon align="inline-end">
- <Select<DrillCategory>
- value={activeChip}
- onValueChange={(value) => {
- posthog.capture('taxonomic filter menu category changed', {
- fromChip: activeChip,
- toChip: value ?? 'all',
- via: 'dropdown',
- })
- setActiveChip(value ?? 'all')
- inputRef.current?.focus()
- }}
- itemToStringLabel={(value) =>
- categoryOptions.find((o) => o.value === value)?.label ?? 'All'
- }
- >
- <SelectTrigger
- size="sm"
- aria-label="Filter category"
- data-attr="menu-filter-category"
- className="mr-0.5"
- >
- <SelectValue />
- </SelectTrigger>
- {/* Fit the list to its items: at least as wide as the
- trigger, grow to the longest option, capped at the
- available viewport width so it never overflows. */}
- <SelectContent
- align="end"
- alignItemWithTrigger={false}
- className="w-max min-w-(--anchor-width) max-w-(--available-width)"
- >
- <SelectGroup>
- {categoryOptions.map((o) => (
- <SelectItem key={o.value} value={o.value}>
- {o.label}
- </SelectItem>
- ))}
- </SelectGroup>
- </SelectContent>
- </Select>
- </InputGroupAddon>
- )}
- </InputGroup>
- </div>
{!drillItems &&
targetGroups.map((g) => (
<Fetcher
@@ -984,6 +1022,102 @@ export function MenuFilterCombobox({
)
}
+interface AutocompleteLemonInputProps {
+ value: string
+ onValueChange: (value: string) => void
+ /** Set alongside base-ui's own ref, so callers (popover `initialFocus`,
+ * category-select refocus) can reach the input element. */
+ sharedInputRef?: MutableRefObject<HTMLInputElement | null>
+ prefix?: ReactElement
+ suffix?: ReactElement
+ placeholder?: string
+ 'data-attr'?: string
+ /** Runs before base-ui's own keydown handler; base-ui's runs only when this
+ * one didn't `preventDefault` (so Esc/Enter/Tab can take precedence over the
+ * autocomplete's arrow-key navigation). */
+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void
+ onPaste?: (e: React.ClipboardEvent<HTMLInputElement>) => void
+}
+
+/**
+ * The single place that bridges base-ui's `Autocomplete.Input` onto a
+ * `LemonInput`. base-ui drives a controlled `<input>` through its `render` prop —
+ * value/onChange/ref/keyboard plus the combobox a11y attrs (`role`,
+ * `aria-activedescendant`, `aria-expanded`, …). `LemonInput`'s typed props don't
+ * include those a11y attrs but its inner `<input>` forwards unrecognised props,
+ * so we strip the props we drive ourselves and pass the rest through. Keeping the
+ * adapter in one named place (rather than inline in the combobox render) means a
+ * base-ui upgrade that changes how it drives the input has exactly one site to
+ * update — the typed destructure below and the input-trigger tests are what guard
+ * the contract.
+ */
+function AutocompleteLemonInput({
+ value,
+ onValueChange,
+ sharedInputRef,
+ prefix,
+ suffix,
+ placeholder,
+ onKeyDown,
+ onPaste,
+ 'data-attr': dataAttr,
+}: AutocompleteLemonInputProps): JSX.Element {
+ return (
+ <Autocomplete.Input
+ value={value}
+ onChange={(e) => onValueChange(e.target.value)}
+ render={(autoProps) => {
+ // Type the incoming contract as input attributes (not `any`), then
+ // peel off the props we own — base-ui's value/onChange/className,
+ // its ref (merged below), and its keydown (composed below).
+ const {
+ ref,
+ value: _baseValue,
+ onChange: _baseOnChange,
+ className: _baseClassName,
+ onKeyDown: baseOnKeyDown,
+ ...baseInputAttrs
+ } = autoProps as React.InputHTMLAttributes<HTMLInputElement> & { ref?: React.Ref<HTMLInputElement> }
+ const setRef = (el: HTMLInputElement | null): void => {
+ if (typeof ref === 'function') {
+ ref(el)
+ } else if (ref) {
+ ;(ref as React.MutableRefObject<HTMLInputElement | null>).current = el
+ }
+ if (sharedInputRef) {
+ sharedInputRef.current = el
+ }
+ }
+ return (
+ <LemonInput
+ // The remaining base-ui attrs (role, aria-activedescendant…)
+ // are valid `<input>` attributes LemonInput forwards but
+ // doesn't type — the one boundary cast the bridge needs.
+ // eslint-disable-next-line react/no-unknown-property
+ {...(baseInputAttrs as Record<string, unknown>)}
+ inputRef={setRef}
+ size="small"
+ fullWidth
+ prefix={prefix}
+ suffix={suffix}
+ data-attr={dataAttr}
+ placeholder={placeholder}
+ value={value}
+ onChange={(next) => onValueChange(next)}
+ onKeyDown={(e) => {
+ onKeyDown?.(e)
+ if (!e.defaultPrevented) {
+ baseOnKeyDown?.(e)
+ }
+ }}
+ onPaste={onPaste}
+ />
+ )
+ }}
+ />
+ )
+}
+
interface RowProps {
entry: MenuFilterEntry
/** Render the category label (mixed-group views always; drilled views skip it since the panel header already names the group). */
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/InputTrigger.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/InputTrigger.tsx
new file mode 100644
index 000000000000..aedf2ed900e1
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/InputTrigger.tsx
@@ -0,0 +1,62 @@
+import { ReactElement } from 'react'
+
+/**
+ * Replay-style trigger for the rebuilt taxonomic menu: a LemonInput search box
+ * with a leading filter-icon button. Focusing/typing in the box opens the
+ * combobox; clicking the icon opens the dropdown menu.
+ *
+ * LemonInput (not quill) so the trigger matches the surrounding scene's UI. The
+ * combobox internals stay quill; when it opens, the popover panel renders its
+ * own live search field (header above, list below) positioned over this row, so
+ * here we render an invisible same-height spacer to hold the anchor in place
+ * and avoid a layout shift behind the panel.
+ */
+import { LemonInput } from 'lib/lemon-ui/LemonInput'
+
+export interface MenuInputTriggerProps {
+ iconButton: ReactElement
+ placeholder?: string
+ value?: string
+ onChange?: (value: string) => void
+ onFocus?: () => void
+ fullWidth?: boolean
+ /** While the combobox panel is open it owns the visible field; the row
+ * holds an invisible spacer so the trigger anchor and layout don't shift. */
+ spacerOnly?: boolean
+}
+
+export function MenuInputTrigger({
+ iconButton,
+ placeholder,
+ value,
+ onChange,
+ onFocus,
+ fullWidth = true,
+ spacerOnly = false,
+}: MenuInputTriggerProps): JSX.Element {
+ if (spacerOnly) {
+ return (
+ <div aria-hidden="true">
+ <LemonInput
+ fullWidth={fullWidth}
+ size="small"
+ disabled
+ placeholder={placeholder}
+ className="invisible"
+ />
+ </div>
+ )
+ }
+ return (
+ <LemonInput
+ fullWidth={fullWidth}
+ size="small"
+ prefix={iconButton}
+ data-attr="taxonomic-filter-menu-input"
+ placeholder={placeholder}
+ value={value}
+ onChange={onChange}
+ onFocus={onFocus}
+ />
+ )
+}
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.inputTrigger.test.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.inputTrigger.test.tsx
new file mode 100644
index 000000000000..9cbbf0fd37be
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.inputTrigger.test.tsx
@@ -0,0 +1,131 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { Provider } from 'kea'
+
+import { useMocks } from '~/mocks/jest'
+import { actionsModel } from '~/models/actionsModel'
+import { groupsModel } from '~/models/groupsModel'
+import { performQuery } from '~/queries/query'
+import { initKeaTests } from '~/test/init'
+
+import { TaxonomicFilterHeadless } from '../headless'
+import { __clearTaxonomicResourceCache } from '../hooks/useTaxonomicResource'
+import { TaxonomicFilterGroupType } from '../types'
+import { TaxonomicFilterMenu } from './TaxonomicFilterMenu'
+
+jest.mock('~/queries/query', () => ({
+ performQuery: jest.fn(),
+}))
+
+jest.mock('posthog-js', () => ({
+ __esModule: true,
+ default: { capture: jest.fn() },
+}))
+
+jest.mock('lib/api', () => {
+ const emptyPaginated = (): Promise<{ results: any[]; count: number; next: null }> =>
+ Promise.resolve({ results: [], count: 0, next: null })
+ return {
+ __esModule: true,
+ default: {
+ get: jest.fn().mockImplementation(emptyPaginated),
+ actions: { list: jest.fn().mockImplementation(emptyPaginated) },
+ dataWarehouseSavedQueries: { list: jest.fn().mockImplementation(emptyPaginated) },
+ dataWarehouseTables: { list: jest.fn().mockImplementation(emptyPaginated) },
+ queryTabState: { list: jest.fn().mockImplementation(emptyPaginated) },
+ dashboards: { list: jest.fn().mockImplementation(emptyPaginated) },
+ cohorts: { listPaginated: jest.fn().mockImplementation(emptyPaginated) },
+ },
+ }
+})
+
+const apiGet = jest.requireMock('lib/api').default.get as jest.MockedFunction<any>
+
+const GROUP_TYPES = [
+ TaxonomicFilterGroupType.EventProperties,
+ TaxonomicFilterGroupType.PersonProperties,
+ TaxonomicFilterGroupType.HogQLExpression,
+]
+
+function renderInputTriggerMenu(): ReturnType<typeof render> {
+ return render(
+ <Provider>
+ <TaxonomicFilterHeadless.Root taxonomicGroupTypes={GROUP_TYPES} onChange={jest.fn()}>
+ <TaxonomicFilterMenu triggerVariant="input" />
+ </TaxonomicFilterHeadless.Root>
+ </Provider>
+ )
+}
+
+describe('TaxonomicFilterMenu input trigger', () => {
+ beforeEach(() => {
+ __clearTaxonomicResourceCache()
+ apiGet.mockReset()
+ apiGet.mockResolvedValue({ results: [], count: 0, next: null })
+ ;(performQuery as jest.Mock).mockResolvedValue({ tables: {}, joins: [] })
+ useMocks({})
+ initKeaTests()
+ actionsModel.mount()
+ groupsModel.mount()
+ })
+
+ afterEach(() => cleanup())
+
+ it('renders a text input and a filter-icon menu button instead of a single button', () => {
+ renderInputTriggerMenu()
+
+ expect(screen.getByTestId('taxonomic-filter-menu-input')).toBeInTheDocument()
+ expect(screen.getByRole('textbox')).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Open filter menu' })).toBeInTheDocument()
+ })
+
+ it('opens the dropdown menu (without a redundant "New filter…" item) when the filter icon is clicked', async () => {
+ renderInputTriggerMenu()
+
+ await userEvent.click(screen.getByRole('button', { name: 'Open filter menu' }))
+
+ // The menu opens — its always-present "HogQL expression" entry confirms it.
+ await waitFor(() => {
+ expect(screen.getByTestId('taxonomic-filter-menu-hogql')).toBeInTheDocument()
+ })
+ // Typing in the box replaces "New filter…", so it must not be offered.
+ expect(screen.queryByTestId('taxonomic-filter-menu-new')).not.toBeInTheDocument()
+ expect(screen.queryByText('New filter…')).not.toBeInTheDocument()
+ // The icon opens the menu, NOT the combobox — guards the `stopPropagation`
+ // that keeps the click from bubbling to the input's focus handler.
+ expect(screen.queryByTestId('menu-filter-search')).not.toBeInTheDocument()
+ })
+
+ it('opens the combobox search panel when the input is focused', async () => {
+ renderInputTriggerMenu()
+
+ await userEvent.click(screen.getByTestId('taxonomic-filter-menu-input'))
+
+ await waitFor(() => {
+ expect(screen.getByTestId('menu-filter-search')).toBeInTheDocument()
+ })
+ // The dropdown menu must not also be open — focusing the input is the
+ // combobox path, not the menu path.
+ expect(screen.queryByTestId('taxonomic-filter-menu-hogql')).not.toBeInTheDocument()
+ })
+
+ it('keeps a single search input — the combobox chrome opens around the trigger box, not a second mirrored input', async () => {
+ renderInputTriggerMenu()
+
+ await userEvent.click(screen.getByTestId('taxonomic-filter-menu-input'))
+
+ await waitFor(() => {
+ expect(screen.getByTestId('menu-filter-search')).toBeInTheDocument()
+ })
+ // The placeholder trigger input is replaced by the search field, not
+ // mirrored alongside it — so there's a single live input, not two.
+ expect(screen.queryByTestId('taxonomic-filter-menu-input')).not.toBeInTheDocument()
+ // The search field renders in the trigger row beside the filter-icon
+ // button (chrome opens around it), not adrift in the popover.
+ const iconButton = screen.getByRole('button', { name: 'Open filter menu' })
+ const searchInput = screen.getByTestId('menu-filter-search')
+ expect(iconButton.closest('.LemonInput')).toContainElement(searchInput)
+ })
+})
diff --git a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
index a375dc2daf98..c92bba2ac10e 100644
--- a/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/menu/TaxonomicFilterMenu.tsx
@@ -25,7 +25,7 @@ import { useValues } from 'kea'
import posthog from 'posthog-js'
import { ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'
-import { IconChevronRight } from '@posthog/icons'
+import { IconChevronRight, IconFilter } from '@posthog/icons'
import {
Button,
cn,
@@ -40,6 +40,7 @@ import {
} from '@posthog/quill'
import { formatPropertyLabel } from 'lib/components/PropertyFilters/utils'
+import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { isDefinitionStale } from 'lib/utils/definitions'
import { getCoreFilterDefinition } from '~/taxonomy/helpers'
@@ -53,6 +54,7 @@ import { filterPinnedForContext, filterRecentsForContext } from '../utils/sugges
import { MenuFilterCombobox } from './Combobox'
import { MenuFilterDwhConfig } from './DwhFlow'
import { MenuFilterHogQLEditor } from './HogQLEditor'
+import { MenuInputTrigger } from './InputTrigger'
import { taxonomicTriggerWrapperClassName } from './triggerLayout'
import {
CommitFn,
@@ -106,6 +108,22 @@ export interface TaxonomicFilterMenuProps {
* callers don't need to add another positioned ancestor of their own.
*/
triggerAccessory?: import('react').ReactNode
+ /**
+ * Trigger presentation. `'button'` (default) is the single dropdown
+ * button. `'input'` renders a replay-style search box with a leading
+ * filter-icon button: focusing/typing in the box opens the combobox,
+ * clicking the icon opens the dropdown menu. Only takes effect while
+ * nothing is `selected` (the add-filter case) — an existing selection
+ * still renders the button so its label is visible.
+ */
+ triggerVariant?: 'button' | 'input'
+ /**
+ * Where `defaultOpen` lands. Defaults to `resolveOpenState()` (menu when
+ * nothing is selected). The input trigger uses this so an open driven by
+ * the search box arrives directly on the combobox while one driven by the
+ * filter icon arrives on the dropdown menu.
+ */
+ defaultOpenState?: 'menu' | 'combobox'
}
export interface TriggerState {
@@ -123,6 +141,26 @@ type MenuOption = 'new' | 'recent' | 'pinned' | 'dwh' | 'hogql'
let lastMenuClosedAtMs: number | null = null
const QUICK_REOPEN_MS = 3000
+// The input-trigger panel is shifted up + left so its search field lands over
+// the trigger row (the input appears to stay put and only widen). The shift
+// equals the field's offset from the panel's top-left, summed from the pieces
+// that produce it — kept as named parts so a change to `MenuFilterHeader`'s
+// spacing or the input row's padding is visibly the thing to keep in sync here.
+const MENU_HEADER_PADDING_Y_PX = 16 // MenuFilterHeader `py-2` (top + bottom)
+const MENU_HEADER_BUTTON_HEIGHT_PX = 24 // "Go back" Button `size="sm"` (h-6)
+const MENU_HEADER_BORDER_PX = 1 // MenuFilterHeader `border-b`
+const SEARCH_ROW_PADDING_PX = 8 // search-field row `p-2` (one side)
+const PANEL_BORDER_PX = 1 // PopoverContent border
+
+/** Panel-top to search-field-top: the header (padding + button + border) plus the
+ * search row's top padding. */
+const INPUT_TRIGGER_PANEL_HEADER_OFFSET =
+ MENU_HEADER_PADDING_Y_PX + MENU_HEADER_BUTTON_HEIGHT_PX + MENU_HEADER_BORDER_PX + SEARCH_ROW_PADDING_PX
+
+/** Panel-left to search-field-left: the panel border plus the search row's left
+ * padding. */
+const INPUT_TRIGGER_PANEL_LEFT_INSET = PANEL_BORDER_PX + SEARCH_ROW_PADDING_PX
+
/** Mirrors legacy `taxonomicFilterLogic`: staleness only applies to event /
* custom-event definitions that carry `last_seen_at`; `undefined` for every
* other selection so the field reads identically across the A/B arms. */
@@ -150,8 +188,10 @@ export function TaxonomicFilterMenu({
fullWidthTrigger = false,
defaultOpen = false,
triggerAccessory,
+ triggerVariant = 'button',
+ defaultOpenState,
}: TaxonomicFilterMenuProps): JSX.Element {
- const { groups, selectItem, inputProps, searchQuery, selectingKeyOnly, excludedOperators } =
+ const { groups, selectItem, inputProps, searchQuery, setSearchQuery, selectingKeyOnly, excludedOperators } =
useTaxonomicFilterContext()
const [state, setState] = useState<MenuFilterState>({ kind: 'closed' })
@@ -263,7 +303,13 @@ export function TaxonomicFilterMenu({
// Runs once — opening is a one-shot mount concern, not reactive.
useEffect(() => {
if (defaultOpen) {
- setState(resolveOpenState())
+ setState(
+ defaultOpenState === 'combobox'
+ ? { kind: 'combobox', drillTo: 'all' }
+ : defaultOpenState === 'menu'
+ ? { kind: 'menu' }
+ : resolveOpenState()
+ )
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
@@ -372,6 +418,18 @@ export function TaxonomicFilterMenu({
const triggerEl: ReactElement =
typeof trigger === 'function' ? trigger(triggerState) : (trigger ?? <Button variant="outline">{label}</Button>)
+ // Replay-style input trigger — only while nothing is selected, so an
+ // existing selection keeps showing its label in the button. The icon is
+ // the dropdown-menu anchor; the input opens (and seeds) the combobox.
+ const useInputTrigger = triggerVariant === 'input' && !selected
+ const inputTriggerPlaceholder = triggerLabel || inputProps.placeholder || 'Add filter'
+
+ // When the input-trigger combobox is open, the popover panel renders the
+ // live search field (header above it, results below) and is shifted up so
+ // that field lands over the trigger row — the chrome wraps the input. The
+ // shared ref lets the popover focus that field on open.
+ const comboboxInputRef = useRef<HTMLInputElement | null>(null)
+
// -- Popover open derives from state. The dropdown menu is a separate
// overlay (DropdownMenu); the popover is open for any non-menu,
// non-closed kind.
@@ -384,6 +442,33 @@ export function TaxonomicFilterMenu({
// table list.
const popoverOpen = state.kind === 'combobox' || state.kind === 'dwh-pick' || state.kind === 'hogql-edit'
+ // `combobox` and `dwh-pick` render a search-field row, so in input-trigger
+ // mode the panel is shifted to overlay that field on the trigger box (and the
+ // trigger yields to an invisible spacer). `hogql-edit` is intentionally
+ // excluded: the code editor has no search-field row to align to, so it opens
+ // as a normal dropdown below the trigger.
+ const comboboxOverlaysTrigger = useInputTrigger && (state.kind === 'combobox' || state.kind === 'dwh-pick')
+
+ // Filter-icon menu anchor, styled to match the scene (LemonButton). Lives
+ // as the field's prefix — in the resting trigger box, and in the combobox's
+ // portaled field while open — so it stays put as the menu opens around it.
+ const inputTriggerIcon = (
+ <DropdownMenuTrigger
+ render={
+ <LemonButton
+ size="small"
+ icon={<IconFilter />}
+ aria-label="Open filter menu"
+ data-attr="taxonomic-filter-menu-trigger"
+ // Stop the click bubbling to the LemonInput wrapper, whose
+ // onClick focuses the input — that would open the combobox
+ // instead of the icon's dropdown menu.
+ onClick={(e) => e.stopPropagation()}
+ />
+ }
+ />
+ )
+
// Manual outside-click handling. base-ui Popover's automatic dismiss
// can't reliably distinguish a click on the visible trigger (the
// DropdownMenuTrigger button) from a click outside, because its own
@@ -522,7 +607,28 @@ export function TaxonomicFilterMenu({
}}
>
<span ref={triggerWrapRef} className={taxonomicTriggerWrapperClassName(fullWidthTrigger)}>
- <DropdownMenuTrigger render={triggerEl} data-attr="taxonomic-filter-menu-trigger" />
+ {useInputTrigger ? (
+ <MenuInputTrigger
+ iconButton={inputTriggerIcon}
+ fullWidth={fullWidthTrigger}
+ placeholder={inputTriggerPlaceholder}
+ value={searchQuery}
+ spacerOnly={comboboxOverlaysTrigger}
+ onChange={(next) => {
+ setSearchQuery(next)
+ if (state.kind !== 'combobox') {
+ openCombobox('all')
+ }
+ }}
+ onFocus={() => {
+ if (state.kind === 'closed') {
+ openCombobox('all')
+ }
+ }}
+ />
+ ) : (
+ <DropdownMenuTrigger render={triggerEl} data-attr="taxonomic-filter-menu-trigger" />
+ )}
<PopoverTrigger
render={<span aria-hidden tabIndex={-1} className="absolute inset-0 pointer-events-none" />}
/>
@@ -531,8 +637,35 @@ export function TaxonomicFilterMenu({
<PopoverContent
align="start"
side="bottom"
- sideOffset={4}
- container={popoverContainer}
+ // Input trigger: shift the panel up by (trigger height +
+ // header + input-row padding) so the panel's search field
+ // lands over the trigger row — header pops above, results
+ // below, the input appears to stay put and just widen. Keep
+ // the side fixed so it can't flip away from that alignment.
+ // Button trigger: a normal dropdown below the button.
+ sideOffset={
+ comboboxOverlaysTrigger
+ ? ({ anchor }) => -(anchor.height + INPUT_TRIGGER_PANEL_HEADER_OFFSET)
+ : 4
+ }
+ // Pull the panel left so its inset search field aligns with
+ // the trigger box horizontally (input appears not to move).
+ alignOffset={comboboxOverlaysTrigger ? -INPUT_TRIGGER_PANEL_LEFT_INSET : 0}
+ // Input trigger: pin the vertical axis so the field stays over
+ // the trigger row, but allow horizontal `shift` so the wide
+ // panel slides left to stay on-screen when the trigger sits near
+ // the right edge (e.g. web-analytics filters) — losing a few px
+ // of horizontal alignment there beats clipping off-screen.
+ // Button trigger: keep it on the vertical axis, never beside.
+ collisionAvoidance={
+ comboboxOverlaysTrigger
+ ? { side: 'none', align: 'shift' }
+ : { side: 'flip', align: 'shift', fallbackAxisSide: 'none' }
+ }
+ container={popoverContainer ?? undefined}
+ // Focus the panel's search field on open (it's outside the
+ // popover's default focusable flow until rendered).
+ initialFocus={comboboxOverlaysTrigger ? comboboxInputRef : undefined}
className={cn(
'p-0 gap-0 overflow-hidden flex flex-col w-[calc(100%_-_2rem)] @[720px]/main-content-container:w-[720px] h-[400px]'
)}
@@ -559,6 +692,8 @@ export function TaxonomicFilterMenu({
selectedEntry={selected ?? null}
onCommit={handleCommit}
onBack={openMenu}
+ inputRef={comboboxInputRef}
+ iconButton={useInputTrigger ? inputTriggerIcon : undefined}
/>
)}
{(state.kind === 'dwh-pick' || state.kind === 'dwh-config') && (
@@ -576,6 +711,8 @@ export function TaxonomicFilterMenu({
}
onCommit={(entry) => openDwhConfig(entry.item, entry.group, 'dwh-pick')}
onBack={openMenu}
+ inputRef={comboboxInputRef}
+ iconButton={useInputTrigger ? inputTriggerIcon : undefined}
/>
)}
{state.kind === 'hogql-edit' && (
@@ -612,16 +749,20 @@ export function TaxonomicFilterMenu({
/>
)}
<DropdownMenuContent align="start" className="min-w-[240px]">
- <DropdownMenuItem
- onClick={() => selectMenuOption('new', () => openCombobox('all'))}
- data-attr="taxonomic-filter-menu-new"
- >
- New filter…
- <IconChevronRight className="ml-auto size-3.5 text-tertiary" />
- </DropdownMenuItem>
+ {/* The input-trigger box already does "type to make a new filter",
+ so the explicit "New filter…" row would be redundant there. */}
+ {!useInputTrigger && (
+ <DropdownMenuItem
+ onClick={() => selectMenuOption('new', () => openCombobox('all'))}
+ data-attr="taxonomic-filter-menu-new"
+ >
+ New filter…
+ <IconChevronRight className="ml-auto size-3.5 text-tertiary" />
+ </DropdownMenuItem>
+ )}
{recentEntries.length > 0 && (
<>
- <DropdownMenuSeparator />
+ {!useInputTrigger && <DropdownMenuSeparator />}
<DropdownMenuItem onClick={() => selectMenuOption('recent', () => openCombobox('recent'))}>
Recent
<IconChevronRight className="ml-auto size-3.5 text-tertiary" />
diff --git a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.inputTrigger.test.tsx b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.inputTrigger.test.tsx
new file mode 100644
index 000000000000..c4ca4bdd0cd2
--- /dev/null
+++ b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.inputTrigger.test.tsx
@@ -0,0 +1,93 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen, waitFor } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { Provider } from 'kea'
+
+import { __clearTaxonomicResourceCache } from 'lib/components/TaxonomicFilter/hooks/useTaxonomicResource'
+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
+
+import { useMocks } from '~/mocks/jest'
+import { actionsModel } from '~/models/actionsModel'
+import { groupsModel } from '~/models/groupsModel'
+import { performQuery } from '~/queries/query'
+import { initKeaTests } from '~/test/init'
+
+import { TaxonomicPopoverMenu } from './TaxonomicPopoverMenu'
+
+jest.mock('~/queries/query', () => ({
+ performQuery: jest.fn(),
+}))
+
+jest.mock('posthog-js', () => ({
+ __esModule: true,
+ default: { capture: jest.fn() },
+}))
+
+jest.mock('lib/api', () => {
+ const emptyPaginated = (): Promise<{ results: any[]; count: number; next: null }> =>
+ Promise.resolve({ results: [], count: 0, next: null })
+ return {
+ __esModule: true,
+ default: {
+ get: jest.fn().mockImplementation(emptyPaginated),
+ actions: { list: jest.fn().mockImplementation(emptyPaginated) },
+ dataWarehouseSavedQueries: { list: jest.fn().mockImplementation(emptyPaginated) },
+ dataWarehouseTables: { list: jest.fn().mockImplementation(emptyPaginated) },
+ queryTabState: { list: jest.fn().mockImplementation(emptyPaginated) },
+ dashboards: { list: jest.fn().mockImplementation(emptyPaginated) },
+ cohorts: { listPaginated: jest.fn().mockImplementation(emptyPaginated) },
+ },
+ }
+})
+
+const apiGet = jest.requireMock('lib/api').default.get as jest.MockedFunction<any>
+
+function renderInputTriggerPopoverMenu(): ReturnType<typeof render> {
+ return render(
+ <Provider>
+ <TaxonomicPopoverMenu
+ groupType={TaxonomicFilterGroupType.EventProperties}
+ groupTypes={[TaxonomicFilterGroupType.EventProperties, TaxonomicFilterGroupType.HogQLExpression]}
+ triggerVariant="input"
+ onChange={jest.fn()}
+ />
+ </Provider>
+ )
+}
+
+describe('TaxonomicPopoverMenu input trigger (lazy placeholder)', () => {
+ beforeEach(() => {
+ __clearTaxonomicResourceCache()
+ apiGet.mockReset()
+ apiGet.mockResolvedValue({ results: [], count: 0, next: null })
+ ;(performQuery as jest.Mock).mockResolvedValue({ tables: {}, joins: [] })
+ useMocks({})
+ initKeaTests()
+ actionsModel.mount()
+ groupsModel.mount()
+ })
+
+ afterEach(() => cleanup())
+
+ it('renders the placeholder input + filter-icon button before arming', () => {
+ renderInputTriggerPopoverMenu()
+
+ expect(screen.getByTestId('taxonomic-filter-menu-input')).toBeInTheDocument()
+ expect(screen.getByRole('button', { name: 'Open filter menu' })).toBeInTheDocument()
+ })
+
+ it('arms to the dropdown menu (not the combobox) when the filter icon is clicked from the resting trigger', async () => {
+ renderInputTriggerPopoverMenu()
+
+ await userEvent.click(screen.getByRole('button', { name: 'Open filter menu' }))
+
+ // The icon arms straight to the menu — its "HogQL expression" entry confirms it.
+ await waitFor(() => {
+ expect(screen.getByTestId('taxonomic-filter-menu-hogql')).toBeInTheDocument()
+ })
+ // It must NOT open the combobox: the icon click must not bubble to the
+ // input's focus handler, which would arm the combobox instead.
+ expect(screen.queryByTestId('menu-filter-search')).not.toBeInTheDocument()
+ })
+})
diff --git a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.tsx b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.tsx
index 94518b9c0ac8..ae6745a4744d 100644
--- a/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.tsx
+++ b/frontend/src/lib/components/TaxonomicPopover/TaxonomicPopoverMenu.tsx
@@ -21,10 +21,12 @@
import { useValues } from 'kea'
import { ReactElement, useMemo, useState } from 'react'
-import { IconChevronDown } from '@posthog/icons'
+import { IconChevronDown, IconFilter } from '@posthog/icons'
+import { InputGroupButton } from '@posthog/quill'
import { TaxonomicFilterHeadless } from 'lib/components/TaxonomicFilter/headless'
import { MenuFilterEntry, TaxonomicFilterMenu } from 'lib/components/TaxonomicFilter/menu'
+import { MenuInputTrigger } from 'lib/components/TaxonomicFilter/menu/InputTrigger'
import { taxonomicTriggerWrapperClassName } from 'lib/components/TaxonomicFilter/menu/triggerLayout'
import {
AllowedProperties,
@@ -92,6 +94,12 @@ export interface TaxonomicPopoverMenuProps<ValueType extends TaxonomicFilterValu
/** Trigger button styling, forwarded so the rebuilt menu's trigger
* matches the legacy `TaxonomicPopover` button at the call site. */
triggerButtonProps?: TriggerButtonProps
+ /**
+ * `'input'` renders a replay-style search box + filter-icon trigger
+ * instead of a single button, while no value is selected. Focusing the
+ * box opens the combobox; clicking the icon opens the dropdown menu.
+ */
+ triggerVariant?: 'button' | 'input'
}
/**
@@ -139,22 +147,58 @@ export function TaxonomicPopoverMenu<ValueType extends TaxonomicFilterValue = Ta
// placeholder button. Mounting the orchestrator for pickers the user
// never opens would multiply mount cost across every call site on a page.
const [armed, setArmed] = useState(false)
+ // Which panel the first interaction should land on once armed. The input
+ // variant has two entry points (search box → combobox, icon → menu); the
+ // button variant always resolves its own open state, so this is ignored.
+ const [armOpenTo, setArmOpenTo] = useState<'menu' | 'combobox'>('combobox')
+
+ const { value, renderValue, placeholder = 'Select', placeholderClass, triggerButtonProps, triggerVariant } = props
+ const useInputTrigger = triggerVariant === 'input' && (value == null || value === '')
if (armed) {
- return <ArmedTaxonomicPopoverMenu {...props} />
+ return <ArmedTaxonomicPopoverMenu {...props} defaultOpenState={useInputTrigger ? armOpenTo : undefined} />
+ }
+
+ const arm = (to: 'menu' | 'combobox'): void => {
+ setArmOpenTo(to)
+ setArmed(true)
}
- const { value, renderValue, placeholder = 'Select', placeholderClass, triggerButtonProps } = props
return (
<span className={taxonomicTriggerWrapperClassName(triggerButtonProps?.fullWidth)}>
- {buildTriggerButton({
- value,
- renderValue,
- placeholder,
- placeholderClass,
- triggerButtonProps,
- onClick: () => setArmed(true),
- })}
+ {useInputTrigger ? (
+ <MenuInputTrigger
+ iconButton={
+ <InputGroupButton
+ variant="outline"
+ size="icon-sm"
+ aria-label="Open filter menu"
+ data-attr="taxonomic-popover-menu-trigger"
+ // Stop the click bubbling to the LemonInput wrapper, whose
+ // onClick focuses the input, whose onFocus arms the combobox.
+ // Without this the icon would open the combobox, not the menu.
+ onClick={(e: React.MouseEvent) => {
+ e.stopPropagation()
+ arm('menu')
+ }}
+ >
+ <IconFilter />
+ </InputGroupButton>
+ }
+ fullWidth={!!triggerButtonProps?.fullWidth}
+ placeholder={typeof placeholder === 'string' ? placeholder : 'Add filter'}
+ onFocus={() => arm('combobox')}
+ />
+ ) : (
+ buildTriggerButton({
+ value,
+ renderValue,
+ placeholder,
+ placeholderClass,
+ triggerButtonProps,
+ onClick: () => setArmed(true),
+ })
+ )}
<TaxonomicMenuToggle />
</span>
)
@@ -185,7 +229,9 @@ function ArmedTaxonomicPopoverMenu<ValueType extends TaxonomicFilterValue = Taxo
suggestedFiltersLabel,
enableKeywordShortcuts,
triggerButtonProps,
-}: TaxonomicPopoverMenuProps<ValueType>): JSX.Element {
+ triggerVariant,
+ defaultOpenState,
+}: TaxonomicPopoverMenuProps<ValueType> & { defaultOpenState?: 'menu' | 'combobox' }): JSX.Element {
// Data warehouse tables carry their column schema (`fields`) in
// `databaseTableListLogic`, not in the bare popover value — needed so
// the DWH config form can render its column dropdowns / preview. Read
@@ -274,9 +320,13 @@ function ArmedTaxonomicPopoverMenu<ValueType extends TaxonomicFilterValue = Taxo
dataWarehousePopoverFields={dataWarehousePopoverFields}
fullWidthTrigger={!!triggerButtonProps?.fullWidth}
triggerAccessory={<TaxonomicMenuToggle />}
+ triggerVariant={triggerVariant}
// Open immediately — this component is mounted in response
- // to the user's first trigger click (see `TaxonomicPopoverMenu`).
+ // to the user's first trigger interaction (see `TaxonomicPopoverMenu`).
+ // `defaultOpenState` routes that open to the panel matching the
+ // interaction: the search box → combobox, the filter icon → menu.
defaultOpen
+ defaultOpenState={defaultOpenState}
trigger={({ open }) =>
buildTriggerButton({ value, renderValue, placeholder, placeholderClass, triggerButtonProps, open })
}
diff --git a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx
index c058fdbaeccb..884dd5f598b7 100644
--- a/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx
+++ b/frontend/src/scenes/insights/filters/ActionFilter/ActionFilterRow/ActionFilterRow.tsx
@@ -700,6 +700,7 @@ export function ActionFilterRow({
excludedProperties={excludedProperties}
hogQLGlobals={hogQLGlobals}
operatorAllowlist={operatorAllowlist}
+ triggerVariant="input"
/>
<SaveAsActionBanner filter={filter} />
</div>
diff --git a/packages/quill/packages/primitives/AGENTS.md b/packages/quill/packages/primitives/AGENTS.md
index 9054ee86c5b6..6c7adaa6883c 100644
--- a/packages/quill/packages/primitives/AGENTS.md
+++ b/packages/quill/packages/primitives/AGENTS.md
@@ -577,6 +577,8 @@ Icon-only trigger — only the chevron toggles, so the label can be its own butt
</Popover>
```
+`PopoverContent` forwards `collisionAvoidance` to the positioner. Pass `fallbackAxisSide: 'none'` to keep a tall panel on its requested axis (e.g. below the trigger, flipping above only if it won't fit) instead of jumping beside the trigger when vertical space is tight: `collisionAvoidance={{ side: 'flip', align: 'shift', fallbackAxisSide: 'none' }}`.
+
### Tooltip
```tsx
diff --git a/packages/quill/packages/primitives/src/popover.tsx b/packages/quill/packages/primitives/src/popover.tsx
index 990713b47f68..c1629b97ed04 100644
--- a/packages/quill/packages/primitives/src/popover.tsx
+++ b/packages/quill/packages/primitives/src/popover.tsx
@@ -18,10 +18,11 @@ function PopoverContent({
alignOffset = 0,
side = 'bottom',
sideOffset = 4,
+ collisionAvoidance,
container,
...props
}: PopoverPrimitive.Popup.Props &
- Pick<PopoverPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'> &
+ Pick<PopoverPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'collisionAvoidance'> &
Pick<PopoverPrimitive.Portal.Props, 'container'>): React.ReactElement {
/*
* `container` opt-in lets consumers mount the popover inside a
@@ -41,6 +42,7 @@ function PopoverContent({
alignOffset={alignOffset}
side={side}
sideOffset={sideOffset}
+ collisionAvoidance={collisionAvoidance}
className="isolate"
>
<PopoverPrimitive.Popup