Skip to content

fix(Select): highlight the selected item on open when its value is "" - #2213

Merged
huntabyte merged 2 commits into
mainfrom
fix/1858-select-reopen-focus
Oct 20, 2026
Merged

huntabyte merged 2 commits into
mainfrom
fix/1858-select-reopen-focus

Conversation

@huntabyte

Copy link
Copy Markdown
Owner

Summary

  • Fixes Select Component: Keyboard focus vanishes when selected + reopened #1858: reopening a Select whose selected item has an empty string value (e.g. an "All" option) now highlights that item instead of falling back to the first item.
  • SelectSingleRootState and SelectMultipleRootState no longer skip the selected-node lookup when the value is "". If no item matches, they still fall back to the first candidate.
  • Combobox: the Enter key handler now checks highlightedValue !== null instead of truthiness, so a highlighted "" item can be selected with Enter.
  • Adds a patch changeset for bits-ui.

Testing

  • Added select-empty-value.browser.test.ts. It covers the following cases:
    • Single Select, with and without a viewport, with the empty item first and last. It selects the empty item, reopens, and checks the item is highlighted and selected, and that arrow-key navigation still works.
    • Multiple Select with value: [""] highlights the empty item on open.
    • Combobox selects a highlighted empty value item with Enter, and the item is highlighted and selected on reopen.
  • Not run: the new browser tests and the rest of the existing suite have not been run as part of writing this description.

- Look up the selected item even when its value is an empty string, in single and multiple selects
- Allow Enter to select a highlighted empty-value item in Combobox
- Add browser tests covering Select, multiple Select and Combobox (#1858)
@changeset-bot

changeset-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d451f68

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
bits-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
bits-ui ✅ Ready (View Log) Visit Preview d451f68

- move the empty-value Select reopen and multiple tests into select.browser.test.ts
- move the empty-value Enter selection test into combobox.browser.test.ts
- remove the standalone select-empty-value.browser.test.ts
@huntabyte
huntabyte merged commit 68d1bf7 into main Oct 20, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 20, 2026

This branch was successfully deployed

1 active deployment
Preview — d451f68c Deployed Oct 20, 2026 by github-actions[bot]
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.

Select Component: Keyboard focus vanishes when selected + reopened

1 participant