: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): join category dropdown to search input (#95331)
Paul D'Ambradcaedea4378f
diff --git a/frontend/src/lib/components/TaxonomicFilter/CategoryDropdown.tsx b/frontend/src/lib/components/TaxonomicFilter/CategoryDropdown.tsxindex b6c5bc939c95..f386e0bdd68e 100644--- a/frontend/src/lib/components/TaxonomicFilter/CategoryDropdown.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/CategoryDropdown.tsx@@ -17,10 +17,12 @@ export function CategoryDropdown({variant,eventName,onAfterChange,+ joinedToInput = false,}: {variant: Exclude<CategoryDropdownVariant, 'control'>eventName?: stringonAfterChange?: () => void+ joinedToInput?: boolean}): JSX.Element | null {const { activeTab, taxonomicGroups, taxonomicGroupTypes } = useValues(taxonomicFilterLogic)const { setActiveTab } = useActions(taxonomicFilterLogic)@@ -71,20 +73,29 @@ export function CategoryDropdown({placement="bottom-start"className={CLICK_OUTSIDE_BLOCK_CLASS}>- {renderTrigger(variant, activeLabel)}+ {renderTrigger(variant, activeLabel, joinedToInput)}</LemonMenu>)}-function renderTrigger(variant: Exclude<CategoryDropdownVariant, 'control'>, activeLabel: string): JSX.Element {+function renderTrigger(+ variant: Exclude<CategoryDropdownVariant, 'control'>,+ activeLabel: string,+ joinedToInput: boolean+): JSX.Element {return (<LemonButton- type="secondary"+ type={joinedToInput ? 'tertiary' : 'secondary'}size="xsmall"+ truncate={joinedToInput}sideIcon={<IconChevronDown />}data-attr={`taxonomic-category-dropdown-trigger-${variant}`}aria-label={`Current category: ${activeLabel}. Click to change.`}- className={CLICK_OUTSIDE_BLOCK_CLASS}+ className={+ joinedToInput+ ? `${CLICK_OUTSIDE_BLOCK_CLASS} TaxonomicFilter__category-dropdown`+ : CLICK_OUTSIDE_BLOCK_CLASS+ }>{activeLabel}</LemonButton>diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.scss b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.scssindex db912c84e103..636c5e0f664d 100644--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.scss+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.scss@@ -33,3 +33,23 @@margin-bottom: 8px;}}++.TaxonomicFilter__search-input--with-category {+ padding-block: 0;+ padding-right: 0;+ overflow: hidden;+}++.TaxonomicFilter__category-dropdown {+ align-self: stretch;+ order: 1;+ min-width: 8rem;+ max-width: 50%;+ height: auto;+ border-left: 1px solid var(--color-border-primary);+ border-radius: 0;++ .LemonButton__chrome {+ min-height: 100%;+ }+}diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsxindex e51b65e64339..5e5513a08c5b 100644--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.test.tsx@@ -1654,6 +1654,23 @@ describe('TaxonomicFilter', () => {})expect(screen.queryByText('Categories')).not.toBeInTheDocument()+ expect(screen.getByTestId('taxonomic-filter-searchfield').closest('.LemonInput')).toHaveClass(+ 'TaxonomicFilter__search-input--with-category'+ )+ expect(screen.getByTestId('taxonomic-category-dropdown-trigger-pill')).toHaveClass(+ 'TaxonomicFilter__category-dropdown',+ 'LemonButton--tertiary',+ 'LemonButton--truncate'+ )++ await userEvent.type(screen.getByTestId('taxonomic-filter-searchfield'), 'x')+ const inputButtons = screen+ .getByTestId('taxonomic-filter-searchfield')+ .closest('.LemonInput')+ ?.querySelectorAll('button')+ expect(inputButtons?.item(inputButtons.length - 1)).toBe(+ screen.getByTestId('taxonomic-category-dropdown-trigger-pill')+ )})it('pill variant: opening the dropdown and picking a category switches the visible results', async () => {diff --git a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsxindex c9e9b8940eff..b9412c98d199 100644--- a/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx+++ b/frontend/src/lib/components/TaxonomicFilter/TaxonomicFilter.tsx@@ -228,15 +228,24 @@ export const TaxonomicFilterSearchInput = forwardRef<const categoriesAreInDropdown = categoryDropdownVariant !== 'control'const categoryDropdown = categoriesAreInDropdown ? (- <CategoryDropdown variant={categoryDropdownVariant} eventName={eventName} onAfterChange={focusInput} />+ <CategoryDropdown+ variant={categoryDropdownVariant}+ eventName={eventName}+ onAfterChange={focusInput}+ joinedToInput+ />) : nullreturn (<LemonInput{...props}ref={ref}+ className={clsx({+ 'TaxonomicFilter__search-input--with-category': categoriesAreInDropdown,+ })}data-attr="taxonomic-filter-searchfield"type="search"+ suffixAfterClear={categoriesAreInDropdown}fullWidthplaceholder={placeholder ?? `Search ${searchPlaceholder}`}value={searchQuery}diff --git a/frontend/src/lib/lemon-ui/LemonInput/LemonInput.tsx b/frontend/src/lib/lemon-ui/LemonInput/LemonInput.tsxindex 86c9294aa991..21c3509f5882 100644--- a/frontend/src/lib/lemon-ui/LemonInput/LemonInput.tsx+++ b/frontend/src/lib/lemon-ui/LemonInput/LemonInput.tsx@@ -44,6 +44,7 @@ interface LemonInputPropsBase extends Pick<prefix?: React.ReactElement | null/** Element to suffix input field */suffix?: React.ReactElement | null+ suffixAfterClear?: boolean/** @deprecated Use `disabledReason` instead and provide a reason. */disabled?: boolean/** Like plain `disabled`, except we enforce a reason to be shown in the tooltip. */@@ -105,6 +106,7 @@ export const LemonInput = React.forwardRef<HTMLDivElement, LemonInputProps>(funcautoWidth,prefix,suffix,+ suffixAfterClear = false,type,value,transparentBackground = false,@@ -196,8 +198,8 @@ export const LemonInput = React.forwardRef<HTMLDivElement, LemonInputProps>(func)suffix = suffix ? (<>- {suffix}- {clearButton}+ {suffixAfterClear ? clearButton : suffix}+ {suffixAfterClear ? suffix : clearButton}</>) : (clearButtondiff --git a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.test.tsx b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.test.tsxindex dc92ddebac3f..7eb4460c51a2 100644--- a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.test.tsx+++ b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.test.tsx@@ -84,6 +84,8 @@ describe('RecordingsUniversalFilterAddFilterPopover (pill category dropdown)', (const pillTrigger = await screen.findByTestId('taxonomic-category-dropdown-trigger-pill')// Defaults to the first group.expect(pillTrigger).toHaveTextContent('Events')+ expect(pillTrigger).toHaveClass('LemonButton--secondary')+ expect(pillTrigger).not.toHaveClass('TaxonomicFilter__category-dropdown', 'LemonButton--truncate')// Type a query so we can prove the surrounding popover is not dismissed by the pick:// the bug routed the menu click through the parent popover's outside-press handler,