Skip to content

[combobox] Respect rendered chips for keyboard navigation - #4572

Merged
atomiks merged 8 commits into
mui:masterfrom
atomiks:codex/combobox-rendered-chip-nav
Apr 13, 2026
Merged

atomiks merged 8 commits into
mui:masterfrom
atomiks:codex/combobox-rendered-chip-nav

Conversation

@atomiks

@atomiks atomiks commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4244

This makes the current Combobox API work for limited-chip rendering when users render a prefix slice of selected values, without adding a new prop/API.

Keyboard navigation and empty-input Backspace now use the rendered chip count instead of the total selected value count, so hidden selections are skipped and the last visible chip is removed.

https://deploy-preview-4572--base-ui.netlify.app/experiments/combobox/limited-chips

Changes

  • Use the rendered chip collection when moving between chips from the input and chip elements.
  • Remove the last rendered chip on empty-input Backspace in multi-select comboboxes.
  • Add regression coverage for sliced chips and a private docs experiment for manual testing.

@atomiks atomiks added type: new feature Expand the scope of the product to solve a new problem. component: combobox Changes related to the combobox component. labels Apr 10, 2026 — with ChatGPT Codex Connector
@pkg-pr-new

pkg-pr-new Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4572
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4572
    

commit: af9ba57

@code-infra-dashboard

code-infra-dashboard Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+79B(+0.02%) 🔺+33B(+0.02%)

Details of bundle changes

Deploy preview

https://deploy-preview-4572--base-ui.netlify.app/


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit af9ba57
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69db6ceaf63ce700086e619d
😎 Deploy Preview https://deploy-preview-4572--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks marked this pull request as ready for review April 10, 2026 06:18
@atomiks
atomiks force-pushed the codex/combobox-rendered-chip-nav branch from 65b31ac to 794c687 Compare April 10, 2026 06:24

atomiks commented Apr 10, 2026

Copy link
Copy Markdown
Contributor Author

Codex Review (GPT-5.4)

Reviewed the full branch against freshly fetched upstream/master, with focused subagent sweeps for accessibility/interaction, tests, and React/state boundaries. Dominant type: bug-fix, with secondary tests, a11y, and private docs experiment coverage.

1. Bugs / Issues (None)

No concrete blocking or non-blocking issues found for the PR’s stated scope: making prefix-limited rendered chips viable without adding a new public limitChips API.

Support Matrix

Case Supported? Realism Notes
Render first N selected chips with value.slice(0, n) and an overflow label Yes 10/10 This matches the limitChips-style workaround and the private experiment.
ArrowLeft from empty input to the last visible chip Yes 10/10 Now uses the rendered chip count instead of total selected values.
ArrowRight from the last visible chip back to the input Yes 10/10 Combobox.Chip now checks chipsRef.current.length.
Empty-input Backspace with hidden trailing values Yes 9/10 Now removes the last rendered chip, not the last hidden selected value.
Combobox.ChipRemove / Delete for prefix-rendered chips Yes 8/10 Rendered chip index still matches selected-value index in the prefix case.
Userland “expand all chips while focused” Yes 7/10 Works as a userland rendering pattern; the PR does not add owned focus-expansion semantics.
Overflow label announcement in the private experiment Yes 8/10 The experiment uses aria-describedby on the input and hidden text like “4 more selected”.
Suffix window, e.g. value.slice(-n) No 3/10 Rendered index no longer maps to selected-value index, so Backspace/removal can target the wrong selected value.
Arbitrary filtering, e.g. hide selected middle items No 4/10 Out of scope for this workaround; would need chip identity/original-index mapping.
Reordered or sorted rendered chips No 5/10 Out of scope for this patch for the same rendered-index vs selected-index reason.
Rendering zero chips while values remain selected Not targeted 2/10 With no rendered chip elements, there is no visible chip target for chip keyboard navigation/removal.

Root Cause & Patch Assessment

The patch addresses the actual blocker for the prefix-limited workaround: chip keyboard navigation and empty-input Backspace were based on selectedValue.length, so hidden selected values could still affect focus and deletion. Using the rendered chip collection fixes that for the “first N chips plus overflow” model without adding public API surface.

The key boundary is that removal still maps rendered chip position back to selectedValue by index. That is acceptable for prefix-preserving rendering, but it should not be described as general support for arbitrary chip projections.

Test Coverage Assessment

The new tests cover the core regression paths: navigation through only rendered chips and Backspace removing the last rendered chip in a sliced-prefix setup. I also ran pnpm test:jsdom ComboboxInput --no-watch, pnpm test:jsdom ComboboxChip --no-watch, and pnpm --filter docs typescript; all passed.

Recommendation

Approve ✅

The branch resolves the original prefix-limited chip workaround blocker and clearly stays inside a small internal behavior change. The unsupported cases are real boundaries, but they are outside the limitChips-style prefix rendering model this PR is enabling.

@atomiks atomiks added type: bug It doesn't behave as expected. and removed type: new feature Expand the scope of the product to solve a new problem. labels Apr 10, 2026

@mnajdova mnajdova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks good. Should we add a public example for it?

@atomiks
atomiks merged commit 299d309 into mui:master Apr 13, 2026
7 checks passed
@atomiks
atomiks deleted the codex/combobox-rendered-chip-nav branch April 13, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: combobox Changes related to the combobox component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[combobox] Add limitChips prop to limit visible selected chips

2 participants