: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(replay): join the category pill to the filter search input (#107396)
Paul D'Ambrac42d2fe5ae02
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex c7ff38fa5ccb..a71732c40b7d 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7774,6 +7774,14 @@ snapshots:hash: v1.k794b7964.7e69e3624663cc25d0f1d66082ee8d238143774157c592a22762d7c065917318._lXov0TI_O-v8nZS_x-dBq3w-ZcVFrfuEQIdkdkx-D8replay-components-propertyicons--wide-width--light:hash: v1.k794b7964.67c144cfc8d89f738f2219f1c9d09bd238134c49721d42b962cd33c76b5ffb95.KWW6Pcggezg8P1DwT8WftuM5E05-mmh2LXDJsBgCA1M+ replay-filters-add-filter-popover--closed--dark:+ hash: v1.k794b7964.5f042350b054b0a5bdc89e906757a8dc3e8ec326a1b9fdd8b96ff49d085d5e73.Ud5F6prPmssf9sTW4FeUNkP3w6Hr3jjVec4JtHI0MC8+ replay-filters-add-filter-popover--closed--light:+ hash: v1.k794b7964.96b26f69ea30de65c06c9a5c6560212a282457b1a4c2d8c93d69cb09e16f73c7.eLGELx_AKoftmQ0cl8oYNeb0tBvCqjnxn4DZww-Hdas+ replay-filters-add-filter-popover--open--dark:+ hash: v1.k794b7964.bc245e0bd57be6f5132f5eb4c26a6bbc77a4f0f7b7452bfb1a3ecc1b46709c42.yuMl99pO0kzzNY0Qhl5nI7SJObDlJp9z8N2MCtyHpFg+ replay-filters-add-filter-popover--open--light:+ hash: v1.k794b7964.4080f7334f9e193fb05511cd995cd581d908f70899ce75791c8a8d63c60c3823.qe1zQijlfLKKWnBKDHrinXnwLaDrf3B_Qd_q_PnRIywreplay-overview-tab--many-other-watchers-overview-tab--dark:hash: v1.k794b7964.131b998b5753ee04c70fcbec9e7208caaedfbbf1f2a49fb33b9cc29a35c182b7.vQJgCoQV7fE9whrQ3bq6m3oEfHLUxAma9aKkDgytWqMreplay-overview-tab--many-other-watchers-overview-tab--light:diff --git a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.stories.tsx b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.stories.tsxnew file mode 100644index 000000000000..c33622f194c8--- /dev/null+++ b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.stories.tsx@@ -0,0 +1,62 @@+import type { Meta, StoryObj } from '@storybook/react'+import { waitFor } from '@testing-library/dom'++import { taxonomicFilterMocksDecorator } from 'lib/components/TaxonomicFilter/__mocks__/taxonomicFilterMocksDecorator'+import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'+import UniversalFilters from 'lib/components/UniversalFilters/UniversalFilters'++import { FilterLogicalOperator, UniversalFiltersGroup } from '~/types'++import { userEvent } from 'storybook/test'++import { RecordingsUniversalFilterAddFilterPopover } from './RecordingsUniversalFiltersEmbed'++const TAXONOMIC_GROUP_TYPES = [+ TaxonomicFilterGroupType.Events,+ TaxonomicFilterGroupType.EventProperties,+ TaxonomicFilterGroupType.PersonProperties,+]++const EMPTY_GROUP: UniversalFiltersGroup = {+ type: FilterLogicalOperator.And,+ values: [{ type: FilterLogicalOperator.And, values: [] }],+}++const meta: Meta = {+ title: 'Replay/Filters/Add filter popover',+ decorators: [taxonomicFilterMocksDecorator],+ render: () => (+ <div className="p-4 w-160">+ <UniversalFilters+ rootKey="replay-add-filter-story"+ group={EMPTY_GROUP}+ onChange={() => {}}+ taxonomicGroupTypes={TAXONOMIC_GROUP_TYPES}+ >+ <RecordingsUniversalFilterAddFilterPopover taxonomicGroupTypes={TAXONOMIC_GROUP_TYPES} />+ </UniversalFilters>+ </div>+ ),+}+export default meta+type Story = StoryObj++export const Closed: Story = {}++function findByDataAttr(container: ParentNode, dataAttr: string): Promise<HTMLElement> {+ return waitFor(() => {+ const element = container.querySelector<HTMLElement>(`[data-attr="${dataAttr}"]`)+ if (!element) {+ throw new Error(`${dataAttr} not rendered yet`)+ }+ return element+ })+}++export const Open: Story = {+ play: async ({ canvasElement }) => {+ await userEvent.click(await findByDataAttr(canvasElement, 'replay-filters-add-filter-input'))+ await userEvent.click(await findByDataAttr(document.body, 'taxonomic-category-dropdown-trigger-pill'))+ await findByDataAttr(document.body, 'taxonomic-category-dropdown-item-events')+ },+}diff --git a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.test.tsx b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.test.tsxindex 0d9044ca61d2..8da1fc978683 100644--- a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.test.tsx+++ b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFilterAddFilterPopover.test.tsx@@ -82,8 +82,12 @@ describe('RecordingsUniversalFilterAddFilterPopover', () => {const pillTrigger = await screen.findByTestId('taxonomic-category-dropdown-trigger-pill')expect(pillTrigger).toHaveTextContent('All')- expect(pillTrigger).toHaveClass('LemonButton--secondary')- expect(pillTrigger).not.toHaveClass('TaxonomicFilter__category-dropdown', 'LemonButton--truncate')+ expect(input.closest('.LemonInput')).toHaveClass('TaxonomicFilter__search-input--with-category')+ expect(pillTrigger).toHaveClass(+ 'TaxonomicFilter__category-dropdown',+ 'LemonButton--tertiary',+ '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,diff --git a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed.tsx b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed.tsxindex dffc1d8569a3..79a1d8af4b82 100644--- a/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed.tsx+++ b/frontend/src/scenes/session-recordings/filters/RecordingsUniversalFiltersEmbed.tsx@@ -614,7 +614,7 @@ export function RecordingsUniversalFilterAddFilterPopover({// clicking the pill from a closed state opens its menu AND focuses the input (which// opens the surrounding popover); the popover portal mounts last and ends up// visually on top of the menu.- const suffix = !isPopoverVisible ? undefined : <CategoryDropdown onAfterChange={focusInput} />+ const suffix = !isPopoverVisible ? undefined : <CategoryDropdown onAfterChange={focusInput} joinedToInput />const closePopover = (): void => {setIsPopoverVisible(false)@@ -636,11 +636,13 @@ export function RecordingsUniversalFilterAddFilterPopover({visible={isPopoverVisible}onClickOutside={closePopover}>- <div className="w-full max-w-[600px] shrink grow-0 @container">+ <div className="w-full max-w-[600px] shrink grow-0"><LemonInput+ className="TaxonomicFilter__search-input--with-category @container"type="search"size="small"fullWidth+ suffixAfterCleardata-attr="replay-filters-add-filter-input"inputRef={inputRef}prefix={<IconSearch />}