Skip to content

fix(forms): use keydown for button active state - #573

Open
cursor[bot] wants to merge 1 commit into
mainfrom
topic/web-modernization/keydown-active-state
Open

cursor[bot] wants to merge 1 commit into
mainfrom
topic/web-modernization/keydown-active-state

Conversation

@cursor

@cursor cursor Bot commented Nov 14, 2026

Copy link
Copy Markdown

Button active state listened for the deprecated keypress event. In the repository-pinned Chromium, preventing default on keypress does not cancel the space-bar scroll that already starts on keydown. StateActiveController now uses keydown, which keeps the active state and stops that scroll.

Removed mechanism

projects/forms/src/internal/controllers/state-active.controller.ts added and removed a keypress listener for keyboard activation. That listener is now keydown.

Native replacement and benefit

keydown is the event that carries the space-bar scroll default action. Calling preventDefault() there cancels the scroll. The same call on keypress is too late.

Measured in Playwright 1.64.1, Chromium revision 1248, runtime 156.0.8078.4, on 2026-11-14 (viewport 600×300, page height 2000px, focusable host, Space held about 80ms):

  • no preventDefault: scrollTop 142
  • preventDefault on keypress: scrollTop 72
  • preventDefault on keydown: scrollTop 0, and the following keypress is suppressed

Compatibility sources

Primary support remains Chrome, per projects/site/src/docs/about/support.md. Firefox and Safari both implement keydown. Firefox has not fired keypress for most non-printable keys since version 65 (Enter is the exception). No public entrypoint changes. The empty @nvidia-elements/core/polyfills export stays published.

Preserved behavior

  • Space and Enter still set :state(active) until keyup, blur, or mouseup.
  • Enter is not preventDefaulted. Space on the host is, including when the control is disabled.
  • Click synthesis for Space and Enter stays on keyup in TypeSubmitController.
  • Command and popover trigger handlers still listen for click. defaultPrevented on keydown does not cancel those clicks.
  • A disabled host does not enter the active state.

Validation

  • Playwright 1.64.1 Chromium revision 1248 (156.0.8078.4) scroll probe, 2026-11-14
  • projects/forms: Prettier check, pnpm run lint, pnpm run test:types, and the unit suite (23 files, 298 tests), including a real Space and Enter active-state test
  • Root mise exec -- pnpm run ci: exit 0
Open in Web View Automation 

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-code-quality

github-code-quality Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: TypeScript

TypeScript / code-coverage/vitest

main 1417043 topic/web-modernizat... 61d9a98 +/-
99% 99% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 15, 2026 03:59 UTC

The active state listened for the deprecated keypress event. This listens
for keydown instead. In Chromium 156, preventDefault on either event
cancels space scrolling, and the active state and keyup click stay the same.

Co-authored-by: crylan <crylan@nvidia.com>
Signed-off-by: Cursor Agent <cursoragent@cursor.com>
@cursor
cursor Bot force-pushed the topic/web-modernization/keydown-active-state branch from 85e0932 to 61d9a98 Compare November 15, 2026 03:51

This branch has not been deployed

No deployments
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.

1 participant