Skip to content

fix: replace deprecated DOM and React APIs - #3327

Merged
interactivellama merged 5 commits into
fix/react-hooks-refsfrom
fix/deprecated-dom-apis
Nov 24, 2026
Merged

interactivellama merged 5 commits into
fix/react-hooks-refsfrom
fix/deprecated-dom-apis

Conversation

@interactivellama

@interactivellama interactivellama commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Part of the v11 merge train, stack 1 "clean CI": ci-warnings → react-hooks-refs → deprecated-dom-apis → deprecated-prop lint (#3311) → rc.1 release (#3342). Private exports shipped in rc.0.

Additional description

This replaces deprecated DOM and React APIs, so the next PR (#3311) can make @typescript-eslint/no-deprecated an error.

  • Moved to rc.0: the KeyboardEvent.key change (fix!, with the Radio keypress fix) shipped in 11.0.0-rc.0 via feat!: v11 RC breaking changes (key values, package exports) #3333, so this PR no longer carries it and is not breaking.
  • substr → slice. substr takes a length and slice an end index, so each call's second argument is converted. A Combobox test pins the highlighted search term (it fails if a conversion is wrong).
  • feat: deprecate onKeyPress on Button, ButtonStateful, Checkbox, Input and Textarea. They still forward it during the 11.x RC, mark it @deprecated pointing to onKeyDown, and log a deprecation warning; 11.0 removes it. One test file covers all five.
  • React 19 types: Input, Textarea and Slider type onInput, onSubmit, onInvalid and onSelect with InputEvent, SubmitEvent and SyntheticEvent instead of the deprecated FormEvent; MutableRefObject casts become RefObject.
  • fix(date-picker): Shift plus a mapped key no longer throws on a calendar day. Root cause: the Shift branch in private/day.tsx checked keyDownCallbacks[event.key] but called shiftKeyDownCallbacks[event.key](), which only maps Tab, so Shift+Arrow, Shift+Space and Shift+Enter threw TypeError: ... is not a function. Shift+Tab was unaffected. The branch now checks the Shift map, so those keys fall through to their unshifted handlers. The bug predates this PR (it was there with keyCode); code review found it because this PR rewrote that block. Regression test: "navigates to previous day with shift held".
  • CHANGELOG entries in the docs commit.
Commits
  • fix: replace deprecated String.prototype.substr with slice
  • feat: deprecate onKeyPress in favor of onKeyDown
  • fix: replace deprecated React FormEvent and MutableRefObject types
  • docs: changelog for the deprecated DOM API fixes
  • fix(date-picker): stop shift+arrow, space and enter from throwing on a calendar day

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 removed this pull request from stack #3324 November 17, 2026 17:47
@interactivellama
interactivellama removed this pull request from stack #3334 November 17, 2026 22:47
@interactivellama
interactivellama removed this pull request from stack #3335 November 17, 2026 23:49
@interactivellama
interactivellama removed this pull request from stack #3336 November 18, 2026 00:38
@interactivellama interactivellama added this to the 11.0.0-rc.0 milestone Nov 18, 2026
@interactivellama
interactivellama removed this pull request from stack #3337 November 18, 2026 00:49
@interactivellama interactivellama changed the title fix!: replace deprecated DOM and React APIs fix: replace deprecated DOM and React APIs Nov 18, 2026
@interactivellama
interactivellama removed this pull request from stack #3339 November 18, 2026 23:30
@interactivellama
interactivellama removed this pull request from stack #3348 November 20, 2026 00:23
@interactivellama
interactivellama force-pushed the fix/deprecated-dom-apis branch 4 times, most recently from 9200d09 to 36084ff Compare November 20, 2026 23:51
substr takes a length and slice takes an end index, so the second argument is
converted at each call. A combobox test pins the highlighted search term.
keypress is a deprecated DOM event. Button, ButtonStateful, Checkbox, Input
and Textarea still forward onKeyPress during the 11.x RC, mark it
@deprecated and warn; 11.0 removes it.
React 19 deprecates FormEvent and MutableRefObject. Input, Textarea and Slider
type onInput, onSubmit, onInvalid and onSelect with InputEvent, SubmitEvent
and SyntheticEvent, matching React's DOM handler types; ref casts use
RefObject.
…a calendar day

The shift branch checked keyDownCallbacks but called shiftKeyDownCallbacks,
which only maps Tab, so any other mapped key held with shift threw a
TypeError.
@interactivellama
interactivellama merged commit 0b1f9e6 into master Nov 24, 2026
9 checks passed
@interactivellama
interactivellama deleted the fix/deprecated-dom-apis branch November 24, 2026 21:45
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