: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(lemon-ui): show all options when focusing a single-select with a value (#63510)
Christiaan Hendriksenaf1368a3b860
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 3285b111bc3b..31c9982aff25 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -3192,6 +3192,10 @@ snapshots:hash: v1.k794b7964.2a51b64245c72cec4c72c007d0d21eaa962a9698331000056c4ce4d9fd9bb60e.UxHh9wpdqsP3vQl3lhImbvCBWgW6UM_kD7nj9N6-irolemon-ui-lemon-input-select--single-option-with-custom--light:hash: v1.k794b7964.25547054385d438f3a862828753585e090d6c8f679761e34e8347b88db0d1a3b.9yiFsLVVZmLLKZdvOcTE9eFvQLmZAWOYXmpR4rlxcWM+ lemon-ui-lemon-input-select--single-select-with-id-keys--dark:+ hash: v1.k794b7964.2663ea7f292a439212adcf439cf6ea6c2b5797c071d5ff8ed73ca80dcb9aa36c.mKKvjf1x7DWGrN7Q0NWAb5Kc-L0081Yath1o7qCBqFw+ lemon-ui-lemon-input-select--single-select-with-id-keys--light:+ hash: v1.k794b7964.f1b800ce7c442ac300a46deecb8fd2a4e610d2327c592ca3a497195bff840ac3.mjVIsRtamHEtE6olJk5yconR0JFa0lKwZk6huHl_oZQlemon-ui-lemon-input-select--snacks-mode-with-sortable--dark:hash: v1.k794b7964.1cde22375021a4e9bc8079fe0936ccd3b7e715838e49abcb9f5944bb48b09922.vbbCUemoM9gCfmCgY3P7Qmzbh3GvsV8qDDKjyxGI_MAlemon-ui-lemon-input-select--snacks-mode-with-sortable--light:diff --git a/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.stories.tsx b/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.stories.tsxindex 4533b60508c2..745286c53d50 100644--- a/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.stories.tsx+++ b/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.stories.tsx@@ -60,6 +60,25 @@ export const Default: Story = {},}+// Single-select where the option keys are opaque ids (e.g. UUIDs) distinct from their labels.+// Focusing with a value selected must still show every option — not just the selected one.+// This is the OAuth organization picker shape, where the bug was first seen.+export const SingleSelectWithIdKeys: Story = {+ render: (args) => {+ const [value, setValue] = useState<string[]>(['019cd764-55e6-0000-67dc-7f9cb756d36e'])+ return <LemonInputSelect {...args} value={value} onChange={setValue} />+ },+ args: {+ mode: 'single',+ placeholder: 'Select an organization',+ options: [+ { key: '019cd764-55e6-0000-67dc-7f9cb756d36e', label: 'Testbench' },+ { key: '4dc8564d-bd82-1065-2f40-97f7c50f67cf', label: 'PostHog Inc.' },+ { key: '018e6669-be95-0000-a135-08054c5d99b4', label: 'Acme Corp' },+ ],+ },+}+export const MultipleSelect: Story = {args: {placeholder: 'Pick email addresses',diff --git a/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.test.tsx b/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.test.tsxindex dbbf739e7d5a..954d66bca1f6 100644--- a/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.test.tsx+++ b/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.test.tsx@@ -247,6 +247,31 @@ describe('LemonInputSelect', () => {expect(onChange).toHaveBeenCalledWith([])})+ it('single-select mode: focusing with a selected option still shows every option', async () => {+ // Regression: for option-backed single selects the option key is an opaque id (e.g. a UUID).+ // Focusing must not seed the input with that key, which would filter the dropdown down to the+ // selected option alone and hide every other choice (the OAuth organization picker symptom).+ const onChange = jest.fn()++ const { container } = render(+ <LemonInputSelect<string>+ mode="single"+ options={[+ { key: '019cd764-55e6-0000-67dc-7f9cb756d36e', label: 'Testbench' },+ { key: '4dc8564d-bd82-1065-2f40-97f7c50f67cf', label: 'PostHog Inc.' },+ ]}+ value={['019cd764-55e6-0000-67dc-7f9cb756d36e']}+ onChange={onChange}+ />+ )++ await openDropdown(container)++ // Both the selected org and the other org must be selectable from the open dropdown.+ expect(await findDropdownButtonByText('Testbench')).toBeInTheDocument()+ expect(await findDropdownButtonByText('PostHog Inc.')).toBeInTheDocument()+ })+it('custom values: typing prefix of existing option shows both entries, completing shows only one', async () => {const onChange = jest.fn()diff --git a/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.tsx b/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.tsxindex b59737774d6c..b94c6db6cd3d 100644--- a/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.tsx+++ b/frontend/src/lib/lemon-ui/LemonInputSelect/LemonInputSelect.tsx@@ -536,8 +536,11 @@ export function LemonInputSelect<T = string>({}const _onFocus = (): void => {- // In single mode, when focusing with a selected value, enter edit mode right away- if (mode === 'single' && values.length > 0 && !inputValue) {+ // In single mode with a free-text (custom) value, seed the input with the current value+ // so the user can edit it. Don't do this for option-backed selects: there the key is an+ // opaque id (e.g. a UUID), and seeding it makes the dropdown filter down to just the+ // selected option, hiding every other choice. Leaving the input empty shows the full list.+ if (mode === 'single' && values.length > 0 && !inputValue && allowCustomValues) {setInputValue(getStringKey(values[0]))}onFocus?.()