Repository navigation
fix!: type RadioGroup onChange and MenuDropdown onClick events as the events they pass - #3349
Merged
interactivellama merged 3 commits intoNov 24, 2026
Merged
Conversation
This was referenced Nov 20, 2026
interactivellama
marked this pull request as draft
November 20, 2026 18:05
interactivellama
force-pushed
the
fix/v11-event-union-types
branch
4 times, most recently
from
November 20, 2026 23:51
7703c9f to
c9fe0c9
Compare
…an be Radio calls onChange with the input's `change` event when a click selects it, but with the `click` event when a click deselects a checked `deselectable` radio (a checked radio fires no `change`), and with the `keydown` event for Enter, and for Space on a checked `deselectable` radio. Radio cast the click to a ChangeEvent, and RadioGroup cast Radio's ChangeEvent | KeyboardEvent to a ChangeEvent, so RadioGroup and RadioButtonGroup's `onChange` was typed as always getting a ChangeEvent. This is the same mismatch as Checkbox's KeyboardEvent cast to a ChangeEvent (#3284). The events themselves predate v11: 0.10.x passed the click and keypress events too, but it had no types. Unlike Checkbox, these keyboard and click paths are real behavior (deselecting, and Enter to select), so the fix is the type, not the handler. Add RadioChangeEvent (ChangeEvent | MouseEvent | KeyboardEvent on the input) and use it for Radio's and RadioGroup's onChange, and drop both casts. ColorPicker's swatch toggle was the one internal handler typed for a ChangeEvent only; it now reads `data.value`. BREAKING CHANGE: RadioGroup and RadioButtonGroup's `onChange` event is typed as `RadioChangeEvent`, and Radio's adds MouseEvent. A handler whose event parameter is annotated as `ChangeEvent` no longer type-checks; read the selection from `data.value`.
…n the menu When Enter, Space, Up or Down on the trigger opens the menu, keyboardNavigate calls the context's handleClick with that keydown event, and MenuDropdown passed it to `onClick` cast `as unknown as MouseEvent`. So `onClick` was typed as always getting a MouseEvent, and a handler reading `clientX` or `button` type-checked and got `undefined` from the keyboard. This is the same KeyboardEvent-as-another-event cast as Checkbox's (#3284). 0.10.x also called onClick with the keypress event, but had no types. Type `onClick`'s event as `MouseEvent | KeyboardEvent`, and build the keyboard context where the keydown event is in scope, so handleClick passes it through without a cast. BREAKING CHANGE: MenuDropdown's `onClick` event is typed as `MouseEvent | KeyboardEvent`. A handler whose event parameter is annotated as `MouseEvent` no longer type-checks.
interactivellama
changed the base branch from
feat/v11-llm-2-migration-guide
to
fix/v11-slds2-css-fixes
November 23, 2026 07:57
interactivellama
force-pushed
the
fix/v11-event-union-types
branch
from
November 23, 2026 07:58
c9fe0c9 to
b73f657
Compare
interactivellama
marked this pull request as ready for review
November 23, 2026 08:40
Niznikr
approved these changes
Nov 23, 2026
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.
Release stack for
11.0.0-rc.1(milestone 11.0.0-rc.1). Base: #3309. The release PR #3342 sits on top of this one.Fixes #
Additional description
Two
onChange/onClickevent types that were narrower than the events the components actually pass. Both are type-only breaking changes; runtime behavior is unchanged. They come out of the type-assertion lint work (the rest of it targets 11.0.0-rc.2), and land in rc.1 so the breaking type changes ship before the RC settles.fix(radio-group)!: type onChange's event as the click or keydown it can beonChangewith the input'schangeevent when a click selects it, but with theclickevent when a click deselects a checkeddeselectableradio (a checked radio fires nochange), and with thekeydownevent for Enter, and Space on a checkeddeselectableradio. Radio cast the clickas ChangeEvent, and RadioGroup cast Radio'sChangeEvent | KeyboardEventas ChangeEvent, soRadioGroup/RadioButtonGrouponChangeclaimed it always got aChangeEvent. 0.10.x passed the same events, but had no types.RadioChangeEvent(ChangeEvent | MouseEvent | KeyboardEventon the input, exported fromcomponents/radio) and use it for Radio's and RadioGroup'sonChange; drop both casts. ColorPicker's swatch toggle, the one internal handler typed forChangeEventonly, now readsdata.value.radio-group.test.jsxasserts the change, click and keydown events reachonChange;radio-group.type-test.tsxfails if aChangeEvent-only handler type-checks again.fix(menu-dropdown)!: type onClick's event as the keydown that can open the menuhandleClickwith thatkeydownevent, which MenuDropdown passed toonClickcastas unknown as MouseEvent. A handler readingclientXorbuttontype-checked and gotundefinedfrom the keyboard. Same pattern as Checkbox's cast fixed in fix!: v11 P1 theme 1, behavior and accessibility fixes #3284.onClick's event asMouseEvent | KeyboardEvent, and build the keyboard context where the keydown event is in scope, so it passes through without a cast.dropdown.test.jsxassertsonClickgets the keydown event on a keyboard open;menu-dropdown.type-test.tsxfails if aMouseEvent-only handler type-checks again.Breaking changes (CHANGELOG
Changed, marked BREAKING):RadioGroupandRadioButtonGrouponChangeeventisRadioChangeEvent, andRadio's addsMouseEvent. A handler annotated(event: ChangeEvent) => …no longer type-checks; read the selection fromdata.value.MenuDropdownonClickeventisMouseEvent | KeyboardEvent. A handler annotated(event: MouseEvent) => …no longer type-checks.No rendered markup changes, so no snapshot diff.
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 and 0 warnings (npm run lint:fixto auto-fix).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).content/visualPickerFigure, render props likerenderItem,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.