Skip to content

[6.x] Fix Combobox not displaying a selected option with a falsy value - #15037

Merged
jasonvarga merged 3 commits into
statamic:6.xfrom
hastinbe:fix/combobox-falsy-modelvalue
Sep 1, 2026
Merged

[6.x] Fix Combobox not displaying a selected option with a falsy value#15037
jasonvarga merged 3 commits into
statamic:6.xfrom
hastinbe:fix/combobox-falsy-modelvalue

Conversation

@hastinbe

Copy link
Copy Markdown
Contributor

selectedOption, canClearSelection, shouldShowInput, and scrollToSelectedOption all used truthy checks on modelValue to detect "nothing selected". A legitimate value of 0, '', or false was treated the same as null, so certain options would never showed as selected in the trigger. Switched to the explicit modelValue === null check selectedOptions already used correctly.

hastinbe and others added 3 commits July 20, 2026 12:59
selectedOption, canClearSelection, shouldShowInput, and
scrollToSelectedOption all used truthy checks on modelValue to detect
"nothing selected". A legitimate value of 0, '', or false was treated
the same as null, so certain options would never showed as
selected in the trigger. Switched to the explicit modelValue === null
check selectedOptions already used correctly.

Signed-off-by: Beau Hastings <beau@saweet.net>
`originalValue` collapsed to `[]` for falsy single values like `0`,
`''`, or `false`, causing the `selected` event to fire again for a
value that was already selected. Same class of bug as the other
`modelValue` checks fixed in this file.
`Combobox.stories.ts` already has an established pattern for testing
Combobox's behaviour via `play` functions tagged `!dev`/`test`, run
against a real browser through `@storybook/addon-vitest`. Replacing
the standalone `Combobox.test.js` with `TestFalsyModelValue` keeps
coverage for this fix consistent with how the rest of the component
is tested.
@jasonvarga
jasonvarga merged commit b76b9c3 into statamic:6.x Sep 1, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants