Skip to content

feat!: v11 P1 theme 3, callback shapes and ref-based focus - #3295

Merged
interactivellama merged 13 commits into
masterfrom
feat/v11-p1-3-callbacks
Nov 11, 2026
Merged

interactivellama merged 13 commits into
masterfrom
feat/v11-p1-3-callbacks

Conversation

@interactivellama

@interactivellama interactivellama commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the theme 3 "callbacks" items in the ROADMAP.md P1 prop API freeze review.

Based on master. Themes 1 (#3284) and 2 (#3285) have merged, so this branch was rebased onto master and the diff shows only theme 3. Theme 4 (slots) stacks on this branch.

Additional description

Callback cleanup for the v11 prop freeze. Callbacks follow (event, data), consumer events objects are read without rebuilding handlers, and the non-native requestFocus/onRequestFocus focus API is removed in favor of refs. One commit per component, with format-only changes in separate style: commits.

Component Change Breaking
button requestFocus/onRequestFocus deprecated (still work, warn once). Focus through ref/buttonRef. SimpleDataTableInteractiveElement now focuses forwardRef children (Button, Checkbox, the internal link) through ref; other wrapped components still get the documented props no
carousel Test only: the real keydown event reaches onRequestPanelChange/onRequestAutoplayToggle (never {} or stale) no
hooks New useLatestRef (utilities/hooks). It updates in an insertion effect, so handlers called from a child's layout effect see the latest callbacks no
color-picker events.onOpen/onClose/onRequestOpen/onRequestClose are wired (they were typed but never called); the top-level props are deprecated. validateColor/validateWorkingColor replace events.onValidate* (deprecated). onRequestClose fires before the state change, with a typed ColorPickerRequestCloseTrigger no
combobox events is read through useLatestRef, so the internal handlers are stable no (fix)
checkbox requestFocus/onRequestFocus deprecated (still work, warn once). Focus through ref no
radio requestFocus/onRequestFocus deprecated (still work, warn once). Focus through refs.input no
simple-data-table onSort(event, { property, sortDirection }) (was (data, event)) and RowActions onAction(event, { item, option }) (was (item, option)). onLoadMore gets (event, { trigger }). Adds SimpleDataTableLoadMoreData and SimpleDataTableRowActionData. The deprecated onFixedHeaderResize gets undefined, not null, without an event. Taken from the closed #3280 yes
date-picker onCalendarFocus gets undefined, not null, as event when a month change moves focus. Keyboard moves still pass the keydown event yes
toast onClickHeadingLink keeps a single (event) argument, typed MouseEvent<HTMLAnchorElement> no

Decisions

  • requestFocus/onRequestFocus are deprecated, not removed: v0.10.65 documents them with no deprecation, and v11 only removes props deprecated in 0.10.x.
  • Removal pattern: as in theme 2. A removed prop leaves the type, is still destructured so it never reaches the DOM, and warns once through sunset-property. A renamed prop keeps working and warns once through deprecated-property.
  • Absent events are undefined: callbacks with no DOM event pass undefined, not null (onLoadMore, onFixedHeaderResize, onCalendarFocus).
  • Value-returning functions are not events: they get get*/validate* names, matching date-picker's parser/formatter (color-picker validateColor/validateWorkingColor).
  • color-picker: if both the events key and the deprecated top-level prop are set, both are called. Uncontrolled, the picker still closes itself; with isOpen passed, the parent decides. onRequestOpen's (event, data) shape is deferred past GA (additive).
  • combobox: typed callback data is deferred past GA (additive).
  • radio: whether Radio forwards ref to the <input> belongs to theme 6.
  • simple-data-table: the only breaking part of feat!: move the remaining callbacks to (event, data) #3280 (argument order), so it lands before GA. The deprecated onChange that feat!: move the remaining callbacks to (event, data) #3280 also touched was already removed on master.
  • toast: a plain click has no component data, so there is no data argument, like a native onClick. Alert's onClickHeadingLink follows the same rule.
  • Deferred past GA (scope cut, additive and non-breaking): date-picker isValid/source, icon-settings getIconPath, modal disableCloseOnClickOutside, edit-dialog handleOpen → onRequestOpen, tooltip/popover getTargetElement, and the rest of the closed feat!: move the remaining callbacks to (event, data) #3280's typed callback data (alert, color-picker onRequestOpen, docked-composer, input/search, pill, filter onClick, edit-dialog onCancel/onSave, split-view listbox onSort, accordion, panel, combobox). They are recorded in ROADMAP.md.

Breaking: simple-data-table and date-picker. CHANGELOG has BREAKING entries with the migrations (swap the onSort/onAction arguments; check !event rather than event === null in onCalendarFocus).

TinyNod (pre-push, advisory): findings, 2 info, none fixed. Both are false positives. The bundle-size note is about a test file, which is not shipped, and the CHANGELOG naming note is generic, with no rule to act on.


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 lint passes with 0 errors (npm run lint:fix to auto-fix). Warnings are the tracked gradual-migration backlog; do not add new errors.
  • npm run typecheck is clean (tsc --noEmit).
  • npm test -- --run passes — this runs both Vitest projects (jsdom unit + real-browser browser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots with npm test -- --run -u and review the diff.
  • npm run build succeeds (type-check + Vite library build + .d.ts + entry shims).

Behavior & docs:

  • First-time contributors: sign the CLA (a bot will comment with instructions).
  • Added/updated Vitest + React Testing Library tests for the change (template: 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.jsx file (the browser project); everything else is jsdom.
  • Reviewed the component's Storybook stories: 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).
  • Story/example code uses the component's real prop API (e.g. slots like content / visualPickerFigure, render props like renderItem, icon props, events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check against components/<name>/__examples__.
  • Storybook Accessibility (a11y) panel shows no new violations for the affected stories.
  • If you added or changed a type, remember runtime PropTypes were removed in the TS migration — types are the contract. Ship accurate .d.ts (they're generated by the build); JS consumers rely on them via editor type-acquisition.

REVIEWER checklist (do not remove)

  • CI is green (GitHub Actions CI workflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.
  • Change has adequate test coverage; bug fixes include a regression test.
  • Reviewed the affected Storybook stories and their a11y panels.
  • Rendered markup still conforms to SLDS — check the story HTML snapshot diff (components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).
  • Public API / package surface: if exports changed, the deep-import contract still holds (@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.

@interactivellama
interactivellama force-pushed the feat/v11-p1-3-callbacks branch 2 times, most recently from e49d76f to c980433 Compare November 11, 2026 07:49
@interactivellama
interactivellama marked this pull request as ready for review November 11, 2026 08:05
Button keeps the requestFocus/onRequestFocus pair working, but both are
marked @deprecated and warn once. They were not deprecated in 0.10.x, so
v11 deprecates them instead of removing them.

SimpleDataTableInteractiveElement now focuses forwardRef components
(Button, Checkbox, the internal link, which is now forwardRef) through
`ref`. Other wrapped components, such as MenuDropdown in row actions,
still receive requestFocus/onRequestFocus.
…lbacks

#3251 already passes the triggering event (or undefined from the autoplay timer) to onRequestPanelChange and onRequestAutoplayToggle. The existing key-path test only checked that the event was truthy, which an empty object also passes.
Handlers that read a consumer's events object through the ref stay stable,
although that object is usually new on every render.
…the validators

- events.onClose, onOpen, onRequestClose and onRequestOpen were typed but
  ignored. They are now called. The top-level props of the same names
  still work, are called after their events counterparts, and warn once.
- events.onRequestClose fires before the popover closes, so a controlled
  parent can keep it open. data.trigger is typed
  ColorPickerRequestCloseTrigger.
- events.onValidateColor/onValidateWorkingColor return a value, so they
  are not events. They become the top-level validateColor and
  validateWorkingColor props. The old keys still work and warn once.
- Handlers read events through useLatestRef, and the events default is
  a module constant, so a new events object no longer rebuilds them.
events was merged into a new object on every render and listed in the
dependencies of every handler, so each render rebuilt requestOpen,
requestClose, the key and input handlers, and everything that depended
on them. The handlers now read the latest events through a ref.
Checkbox keeps the requestFocus/onRequestFocus pair working, but both
are marked @deprecated and warn once. They were not deprecated in
0.10.x, so v11 deprecates them instead of removing them. Focus the
checkbox through `ref`, which is forwarded to the `<input>`.
Radio keeps the requestFocus/onRequestFocus pair working, but both are marked @deprecated
and checkDeprecatedProps warns once. They were not deprecated in 0.10.x, so v11 deprecates
them instead of removing them. Focus the radio through `refs.input`: keep the `<input>` it
receives and call `.focus()`.
onSort was called as (data, event) and RowActions onAction as
(item, option). Both now follow the (event, data) convention:
onSort(event, { property, sortDirection }) and
onAction(event, { item, option }). onLoadMore, which took no arguments,
now receives (event, { trigger }). The examples and tests use the new
signatures. The deprecated onChange(selection, event) is unchanged; it
already warns and points to onRowChange.

BREAKING CHANGE: SimpleDataTable onSort is called as
onSort(event, { property, sortDirection }) instead of
onSort({ property, sortDirection }, event), and SimpleDataTableRowActions
onAction as onAction(event, { item, option }) instead of
onAction(item, option).
…out an event

When the calendar moves focus because a new month rendered, there is no
DOM event. onCalendarFocus now gets `undefined` for it, like
SimpleDataTable onLoadMore and onFixedHeaderResize, instead of `null`.
Keyboard moves still pass the keydown event.

BREAKING CHANGE: DatePicker onCalendarFocus receives `undefined`, not
`null`, as `event` after a month change. Replace `event === null` with
`!event` or `event === undefined`.
onClickHeadingLink keeps its single `(event)` argument: it is a plain click with no component
data, like a native onClick. The event is now typed React.MouseEvent<HTMLAnchorElement>.
@interactivellama
interactivellama merged commit 85d7903 into master Nov 11, 2026
11 checks passed
@interactivellama
interactivellama deleted the feat/v11-p1-3-callbacks branch November 11, 2026 19:34
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.

2 participants