Repository navigation
fix(combobox)!: route action items to events.onSelectActionItem, never onSelect - #3243
Merged
Merged
Conversation
`optionsSearchEntity` (header) and `optionsAddItem` (footer) items took
two different code paths. A mouse click went through option selection,
so the action item itself was sent to `onSelect` as the new selection.
Enter called the item's undocumented `onClick` and returned early,
leaving the menu open, and did nothing when no `onClick` was given.
Both inputs now go through `handleSelect`. If the item has `onClick`, it
is called with `(event, { option })`, the menu closes, and the selection
is left alone. Without `onClick`, both inputs keep the existing mouse
behavior and fire `onSelect`.
Adds an exported `ComboboxActionItem` type that documents `onClick` and
`disabled`. `ComboboxOption` is unchanged.
…r onSelect
`optionsSearchEntity` and `optionsAddItem` rows behaved differently by input
method. Clicking a row skipped the item's `onClick` and called `onSelect`
(and in single-select variants pushed the action row into `selection`),
while Enter called the item's `onClick` and skipped `onSelect`. Consumers
had to wire both paths and filter sentinel ids out of `onSelect`.
Root cause: the menu sent every row click through `handleSelect`, while
`handleInputSubmit` special-cased `type: 'header' | 'footer'` and called
`option.onClick` directly. The two paths never converged.
Action rows are now commands, not options:
- Click and Enter both go through `handleSelect`, which detects action rows
via a module-private symbol that combobox sets only when it builds rows
from the two props. It calls the deprecated item `onClick`
(if any), then `events.onSelectActionItem(event, { option, value })`,
closes the menu, and returns without touching `onSelect` or selection.
- Disabled action rows do nothing for click or Enter and render
`aria-disabled="true"`.
- Item `onClick` is deprecated (deprecated-property warning, removal in
v12). Its signature on `ComboboxActionItem` is widened to
`(event: MouseEvent | KeyboardEvent, { option })`. `ComboboxOption.onClick`
keeps its old type and its old behavior (Enter on a `type: 'header' |
'footer'` row passed directly in `options`), and is marked `@deprecated`.
How #3242 (v11 prop-API freeze review) shaped this:
- It flags callback-presence mode switches as a smell (input-icon, pill).
The first version of this fix used one, routing to `onSelect` only when
`onClick` was absent. Now both handlers are dispatched independently.
- "`onSelect` is really a request." An action row is not a selection
request, so it gets its own callback instead of overloading `onSelect`.
- It keeps Combobox's grouped `events` object. The new callback lives
there, with the repo's `(event, data)` convention.
- Discriminated unions are preferred, and `type: ... | string` collapses
them. Action rows are marked with a module-private symbol instead of
another `type` string, so consumer rows in `options` (any `type`, any
extra keys) can't be mistaken for action items.
- The controlled-`isOpen` close bug is already tracked there. This fix
reuses `handleClose()` and leaves that bug out of scope.
The design was debated with an adversarial reviewer (Codex) over three
rounds. Round 1 changed `ComboboxOption.onClick` in place, which broke
consumer types, so the widened signature moved to `ComboboxActionItem`.
Round 2 typed the payload `option` as `ComboboxActionItem`, which hands
back the consumer's own item object. Round 3 found that a string
`actionItem` key could be spoofed by consumer data (crashing on
`actionItem: null`) and that header/footer rows passed directly in
`options` lost their Enter `onClick`. Both are fixed with regression
tests, and the deprecation test now runs against a fresh module.
BREAKING CHANGE: choosing an `optionsSearchEntity` or `optionsAddItem` row
by mouse no longer calls `onSelect` or adds the row to `selection`.
Migrate sentinel-id checks from `events.onSelect` to
`events.onSelectActionItem`. Rows that only use the item `onClick` keep
working for click and Enter, with a deprecation warning. Rows with
`type: 'header' | 'footer'` passed directly in `options` are unchanged.
interactivellama
approved these changes
Oct 26, 2026
9 of 15 tasks
interactivellama
added a commit
that referenced
this pull request
Nov 16, 2026
Everything since alpha.4 sat under [Unreleased]. Split it by release using the CHANGELOG at each tag: each entry goes in the first release whose tag had it, with that tag's wording. Entries first written after alpha.10 stay under [Unreleased]. Add entries for the 18 PRs in alpha.5 to alpha.7 that shipped without one, from their commit messages. This includes three breaking changes: Combobox action rows moving to events.onSelectActionItem (#3243), the discriminated-union prop types including Combobox option category (#3252), and Badge style/styleIcon (#3256). State how the section maps to a major/minor/patch level, and fix the compare links to use the real tag names.
interactivellama
added a commit
that referenced
this pull request
Nov 17, 2026
Everything since alpha.4 sat under [Unreleased]. Split it by release using the CHANGELOG at each tag: each entry goes in the first release whose tag had it, with that tag's wording. Entries first written after alpha.10 stay under [Unreleased]. Add entries for the 18 PRs in alpha.5 to alpha.7 that shipped without one, from their commit messages. This includes three breaking changes: Combobox action rows moving to events.onSelectActionItem (#3243), the discriminated-union prop types including Combobox option category (#3252), and Badge style/styleIcon (#3256). State how the section maps to a major/minor/patch level, and fix the compare links to use the real tag names.
interactivellama
added a commit
that referenced
this pull request
Nov 18, 2026
Everything since alpha.4 sat under [Unreleased]. Split it by release using the CHANGELOG at each tag: each entry goes in the first release whose tag had it, with that tag's wording. Entries first written after alpha.10 stay under [Unreleased]. Add entries for the 18 PRs in alpha.5 to alpha.7 that shipped without one, from their commit messages. This includes three breaking changes: Combobox action rows moving to events.onSelectActionItem (#3243), the discriminated-union prop types including Combobox option category (#3252), and Badge style/styleIcon (#3256). State how the section maps to a major/minor/patch level, and fix the compare links to use the real tag names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Additional description
Symptom. Header rows (
optionsSearchEntity, e.g. "Search in Accounts") and footer rows (optionsAddItem, e.g. "+ New Account") behaved differently depending on input:onClickignored. Row sent toonSelectas the new selection (single-select examples showed "New Account" as the value)onClickcalled,onSelectskipped, menu stays openonClick(deprecated) thenevents.onSelectActionItem(event, { option, value }), menu closes,onSelectnot fired, selection untouchedaria-disabled="true"optionis the consumer's own item object.valueis the current input text (for "Search for 'acme' in Accounts").Root cause. Two code paths for one row.
Menusends header/footer clicks intohandleSelect, which treats them like any option.handleInputSubmitspecial-cased header/footer to callactiveOption.onClickand return early, without closing. ThatonClickwas never in theoptionsAddItem/optionsSearchEntitytypes. The same split exists in 0.10.x (git show 520f86bb7~1:components/combobox/combobox.jsx, lines ~771 and ~1047), so it predates the v11 rewrite.Fix. Action rows are commands, not options. Combobox builds them from the two props and marks them with a module-private symbol. Both click and Enter reach
handleSelect, which dispatches the action callbacks and returns before any selection logic.Breaking change and migration
Choosing an action row by mouse no longer calls
onSelector adds the row toselection.onSelect(e.g.if (selection[0].id === 'new') openModal()): move that toevents.onSelectActionItem.onClick: keeps working for click and Enter, with a one-time deprecation warning. If bothonClickandonSelectActionItemare set, both are called (onClickfirst). Removal is planned for v12.options(not via the two props): unchanged. Enter still callsoption.onClickand click still goes toonSelect.ComboboxOption.onClickis marked@deprecatedwith that scope.Commit is
fix(combobox)!:with aBREAKING CHANGE:footer. We're in the v11 alpha, which is the window for this.How #3242 shaped this
The first version of this PR fixed the inconsistency by switching modes on whether the item had
onClick(hasonClick→ call it; noonClick→onSelect). Reading #3242 (v11 prop-API freeze review) changed the design:onClickandevents.onSelectActionItemare dispatched independently. Neither one changes what the other does.onSelectis really a request." An action row isn't a request to change the selection, so routing it throughonSelectwas the wrong channel. It gets its own callback.eventsobject. docs: add v11 prop API freeze review to roadmap #3242 keeps Combobox'sevents. The new callback lives there and follows the(event, data)convention.type: ... | stringcollapses discriminated unions. That's why action rows aren't identified bytype === 'header'. Consumer rows can carry anytypeand any extra key. A private symbol is the only marker consumers can't collide with (see Codex round 3 below).isOpenclose bug is already tracked there. This PR reuseshandleClose()and leaves that fix to the docs: add v11 prop API freeze review to roadmap #3242 follow-up instead of widening scope.Review
The design was debated with Codex (
codex exec, read-only sandbox) across three rounds:ComboboxOption.onClick's signature broke existing consumer code (option.onClick?.(event)). The widened signature moved to the newComboboxActionItemtype.optionwas typed asComboboxOption; retyped asComboboxActionItem. In the design debate Codex conceded the mode-switch point (from docs: add v11 prop API freeze review to roadmap #3242), proposed independent dispatch over a precedence fallback, and agreed to keep theisOpenfix and the row union out of scope/private. NamingonSelect…overonRequest…follows the LBC button-menuselectprecedent.actionItemdiscriminator could be spoofed by consumer data (actionItem: nullwould crash), and header/footer rows passed directly inoptionslost their EnteronClick. It also found the deprecation test was order-dependent. All three are fixed with regression tests.Commits
style(combobox): Prettier on touched files (lint-staged would otherwise fold ~1200 lines of reformatting into the fix).fix(combobox): first version (callback-presence routing). Superseded by 4.style(combobox): Prettier onmenu.tsx.fix(combobox)!: the final design. Review 2 and 4 together, or the squashed diff.Tests
components/combobox/__tests__/combobox.test.jsx, "Action items": {header, footer} × {mouse, keyboard} foronSelectActionItempayload/close/no-onSelect, no handler, deprecatedonClickordering, disabled +aria-disabled; plus the deprecation warning (fresh module, exact count per prop), legacy direct header/footer rows, and an ordinary option carrying anactionItemkey.npm run test:ci: 1033 tests pass, build OK, lint 0 errors. No story snapshot changes. TheSearchAndAddEntitiesstory and examples now wireonSelectActionItem.Context: raised by the GUS team (PFT Browser), who use Combobox as a lookup with "+ New" and "Show more results" rows. We haven't verified their current wiring; they may need the
onSelect→onSelectActionItemmigration above.CONTRIBUTOR checklist (do not remove)
Please complete for every pull request.
Green gate — all of these must pass locally (CI runs the same):
npm run lintpasses with 0 errors (npm run lint:fixto auto-fix). Warnings are the tracked gradual-migration backlog; do not add new errors.npm run typecheckis clean (tsc --noEmit).npm test -- --runpasses — this runs both Vitest projects (jsdomunit+ real-browserbrowser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots withnpm test -- --run -uand review the diff.npm run buildsucceeds (type-check + Vite library build +.d.ts+ entry shims).Behavior & docs:
components/button/__tests__). New props and bug fixes should get a regression test. Tests that genuinely need a real browser (focus traversal, layout/measurement, canvas) go in a*.browser.test.jsxfile (thebrowserproject); everything else is jsdom.npm run storybook→ http://localhost:6007/. Confirm the story actually renders and behaves (deprecated Storyshots/Karma are gone; there is no separate browser-tests server).onRenderContent/onRenderVisualPicker,iconprops,events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check againstcomponents/<name>/__examples__..d.ts(they're generated by the build); JS consumers rely on them via editor type-acquisition.REVIEWER checklist (do not remove)
CIworkflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).@salesforce/design-system-react/components/<name>and nested paths resolve for ESM, CJS, and types). Removing/renaming a public component or export is a breaking change →feat!:/BREAKING CHANGE:and a major version bump.