: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(flags): isolate tag select dropdown state per instance (#66435)
Phill41afb42b5dc5
diff --git a/frontend/src/lib/components/TagSelect.tsx b/frontend/src/lib/components/TagSelect.tsxindex bb80e4e25449..dc326e0f08c1 100644--- a/frontend/src/lib/components/TagSelect.tsx+++ b/frontend/src/lib/components/TagSelect.tsx@@ -1,4 +1,5 @@import { useActions, useValues } from 'kea'+import { useId } from 'react'import { LemonButton, LemonButtonProps, LemonDropdown, LemonDropdownProps, LemonInput } from '@posthog/lemon-ui'@@ -9,6 +10,8 @@ export type TagSelectProps = {value: string[]onChange: (value: string[]) => voidchildren?: (selectedTags: string[]) => LemonDropdownProps['children']+ /** Distinguishes the logic instance so multiple selects on one page keep independent open/search state. */+ logicKey?: string}export function TagSelect({@@ -16,10 +19,13 @@ export function TagSelect({value,onChange,children,+ logicKey,...buttonProps}: TagSelectProps & Pick<LemonButtonProps, 'type' | 'size'>): JSX.Element {- const { filteredTags, search, showPopover } = useValues(tagSelectLogic)- const { setSearch, setShowPopover } = useActions(tagSelectLogic)+ const fallbackKey = useId()+ const logic = tagSelectLogic({ logicKey: logicKey ?? fallbackKey })+ const { filteredTags, search, showPopover } = useValues(logic)+ const { setSearch, setShowPopover } = useActions(logic)const _onChange = (newTags: string[]): void => {onChange(newTags)diff --git a/frontend/src/lib/components/tagSelectLogic.ts b/frontend/src/lib/components/tagSelectLogic.tsindex 7ccb9ad0a03f..33c7d01b923e 100644--- a/frontend/src/lib/components/tagSelectLogic.ts+++ b/frontend/src/lib/components/tagSelectLogic.ts@@ -1,11 +1,17 @@-import { actions, connect, kea, path, reducers, selectors } from 'kea'+import { actions, connect, kea, key, path, props, reducers, selectors } from 'kea'import { tagsModel } from '~/models/tagsModel'import type { tagSelectLogicType } from './tagSelectLogicType'+export interface TagSelectLogicProps {+ logicKey: string+}+export const tagSelectLogic = kea<tagSelectLogicType>([- path(['lib', 'components', 'tagSelectLogic']),+ props({} as TagSelectLogicProps),+ key((props) => props.logicKey),+ path((logicKey) => ['lib', 'components', 'tagSelectLogic', logicKey]),connect(() => ({values: [tagsModel, ['tags']],})),