Repository navigation
fix(Button, IconButton, ToggleButton): a held Enter key is one press - #9997
HelloOjasMutreja wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Button · Storybook | 60.4 kB (not measured) · 10.0 kB CSS (not measured) | 691 (not measured) | ✓ · ✓ · ✗ |
| AlertDialog | 105.6 kB (not measured) · 14.6 kB CSS (not measured) | — | — · — · — |
| AppShell | 91.0 kB (not measured) · 13.5 kB CSS (not measured) | — | — · — · — |
73 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Banner | 62.4 kB (not measured) · 10.5 kB CSS (not measured) | — | — · — · — |
| BaseTypeahead | 71.2 kB (not measured) · 10.9 kB CSS (not measured) | — | — · — · — |
| BreadcrumbItem | 84.8 kB (not measured) · 12.1 kB CSS (not measured) | — | — · — · — |
| Calendar | 71.4 kB (not measured) · 10.6 kB CSS (not measured) | — | — · — · — |
| Carousel | 70.0 kB (not measured) · 10.9 kB CSS (not measured) | — | — · — · — |
| ChatComposer | 78.4 kB (not measured) · 12.0 kB CSS (not measured) | — | — · — · — |
| ChatComposerInput | 76.0 kB (not measured) · 11.3 kB CSS (not measured) | — | — · — · — |
| ChatComposerTokenElement | 76.0 kB (not measured) · 11.3 kB CSS (not measured) | — | — · — · — |
| ChatDictationButton | 61.0 kB (not measured) · 10.0 kB CSS (not measured) | — | — · — · — |
| ChatLayout | 83.0 kB (not measured) · 10.5 kB CSS (not measured) | — | — · — · — |
| ChatLayoutScrollButton | 60.9 kB (not measured) · 10.2 kB CSS (not measured) | — | — · — · — |
| ChatSendButton | 60.8 kB (not measured) · 10.0 kB CSS (not measured) | — | — · — · — |
| CodeBlock | 75.4 kB (not measured) · 11.3 kB CSS (not measured) | — | — · — · — |
| ComplexSelector | 71.1 kB (not measured) · 11.8 kB CSS (not measured) | — | — · — · — |
| ContextMenu | 108.4 kB (not measured) · 17.4 kB CSS (not measured) | — | — · — · — |
| DateInput | 186.9 kB (not measured) · 17.0 kB CSS (not measured) | — | — · — · — |
| DateRangeInput | 92.8 kB (not measured) · 12.5 kB CSS (not measured) | — | — · — · — |
| DateTimeInput | 208.6 kB (not measured) · 18.7 kB CSS (not measured) | — | — · — · — |
| DialogHeader | 63.2 kB (not measured) · 11.5 kB CSS (not measured) | — | — · — · — |
| DrawerHeader | 63.4 kB (not measured) · 12.9 kB CSS (not measured) | — | — · — · — |
| DropdownMenu | 97.3 kB (not measured) · 17.6 kB CSS (not measured) | — | — · — · — |
| FileInput | 69.3 kB (not measured) · 10.9 kB CSS (not measured) | — | — · — · — |
| IconButton | 60.5 kB (not measured) · 10.0 kB CSS (not measured) | — | — · — · — |
| Lightbox | 122.6 kB (not measured) · 10.6 kB CSS (not measured) | — | — · — · — |
| Markdown | 187.6 kB (not measured) · 20.6 kB CSS (not measured) | — | — · — · — |
| MobileNav | 70.7 kB (not measured) · 10.6 kB CSS (not measured) | — | — · — · — |
| MobileNavToggle | 60.7 kB (not measured) · 10.0 kB CSS (not measured) | — | — · — · — |
| MoreMenu | 97.5 kB (not measured) · 17.6 kB CSS (not measured) | — | — · — · — |
| MultiSelector | 94.9 kB (not measured) · 16.8 kB CSS (not measured) | — | — · — · — |
| NumberInput | 71.9 kB (not measured) · 11.4 kB CSS (not measured) | — | — · — · — |
| Pagination | 110.0 kB (not measured) · 17.8 kB CSS (not measured) | — | — · — · — |
| Popover | 91.1 kB (not measured) · 14.2 kB CSS (not measured) | — | — · — · — |
| PowerSearch | 287.2 kB (not measured) · 24.1 kB CSS (not measured) | — | — · — · — |
| Selector | 99.9 kB (not measured) · 17.4 kB CSS (not measured) | — | — · — · — |
| SideNav | 114.2 kB (not measured) · 11.4 kB CSS (not measured) | — | — · — · — |
| SideNavCollapseButton | 61.3 kB (not measured) · 10.0 kB CSS (not measured) | — | — · — · — |
| SideNavHeading | 75.7 kB (not measured) · 11.3 kB CSS (not measured) | — | — · — · — |
| SideNavItem | 70.6 kB (not measured) · 11.1 kB CSS (not measured) | — | — · — · — |
| Stepper | 62.0 kB (not measured) · 10.1 kB CSS (not measured) | — | — · — · — |
| Table | 124.9 kB (not measured) · 18.3 kB CSS (not measured) | — | — · — · — |
| TableCell | 109.7 kB (not measured) · 17.9 kB CSS (not measured) | — | — · — · — |
| TableHeaderCell | 109.2 kB (not measured) · 17.7 kB CSS (not measured) | — | — · — · — |
| TableSelectionToolbar | 70.7 kB (not measured) · 13.2 kB CSS (not measured) | — | — · — · — |
| TabMenu | 71.9 kB (not measured) · 11.1 kB CSS (not measured) | — | — · — · — |
| TextInput | 67.9 kB (not measured) · 11.2 kB CSS (not measured) | — | — · — · — |
| Thumbnail | 64.8 kB (not measured) · 11.6 kB CSS (not measured) | — | — · — · — |
| TimeInput | 162.4 kB (not measured) · 16.0 kB CSS (not measured) | — | — · — · — |
| Timestamp | 33.2 kB (not measured) · 10.2 kB CSS (not measured) | — | — · — · — |
| Toast | 98.3 kB (not measured) · 10.3 kB CSS (not measured) | — | — · — · — |
| ToggleButton | 86.8 kB (not measured) · 10.1 kB CSS (not measured) | — | ✓ · ✓ · — |
| ToggleButtonGroup | 39.2 kB (not measured) · 3.7 kB CSS (not measured) | — | ✓ · ✓ · ✓ |
| Tokenizer | 91.6 kB (not measured) · 18.8 kB CSS (not measured) | — | — · — · — |
| TopNav | 72.4 kB (not measured) · 10.9 kB CSS (not measured) | — | — · — · — |
| TopNavHeading | 75.3 kB (not measured) · 11.2 kB CSS (not measured) | — | — · — · — |
| TopNavMegaMenu | 69.9 kB (not measured) · 11.8 kB CSS (not measured) | — | — · — · — |
| TopNavMenu | 74.7 kB (not measured) · 11.2 kB CSS (not measured) | — | — · — · — |
| Typeahead | 79.8 kB (not measured) · 12.4 kB CSS (not measured) | — | — · — · — |
| lab/ChatEmojiPicker | 106.1 kB (not measured) · 773 B CSS (not measured) | — | — · — · — |
| lab/ChatReactionBar | 107.2 kB (not measured) · 1.1 kB CSS (not measured) | — | — · — · — |
| lab/CommentComposer | 151.9 kB (not measured) · 1.9 kB CSS (not measured) | — | — · — · — |
| lab/Comments | 351.0 kB (not measured) · 2.5 kB CSS (not measured) | — | — · — · — |
| lab/CommentThread | 344.1 kB (not measured) · 2.4 kB CSS (not measured) | — | — · — · — |
| lab/DialogHeroHeader | 83.4 kB (not measured) · 372 B CSS (not measured) | — | — · — · — |
| lab/DiffViewer | 87.4 kB (not measured) · 2.1 kB CSS (not measured) | — | — · — · — |
| lab/EmojiPicker | 87.0 kB (not measured) · 751 B CSS (not measured) | — | — · — · — |
| lab/ListInput | 88.4 kB (not measured) · 922 B CSS (not measured) | — | — · — · — |
| lab/Schedule | 106.2 kB (not measured) · 3.9 kB CSS (not measured) | — | — · — · — |
| lab/TourStep | 97.4 kB (not measured) · 590 B CSS (not measured) | — | — · — · — |
| lab/TransferList | 101.7 kB (not measured) · 1.2 kB CSS (not measured) | — | — · — · — |
| lab/TransferListSelector | 109.2 kB (not measured) · 1.4 kB CSS (not measured) | — | — · — · — |
| richtext/RichTextEditor | 297.5 kB (not measured) · 2.6 kB CSS (not measured) | — | — · — · — |
| richtext/RichTextEditorToolbar | 278.2 kB (not measured) · 454 B CSS (not measured) | — | — · — · — |
| richtext/RichTextView | 276.4 kB (not measured) · 2.3 kB CSS (not measured) | — | — · — · — |
Package size: measured; main has no measurement of the merge base to compare yet.
API changes: not compared: no built surface of the merge base; unknown: cli, core, theme-butter, theme-y2k
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approval waits on one engineering-owner decision; no code changes are requested.
- No current Button-family spec says a held Enter is one press:
component:ButtonAR2 andfamily:buttonsFR2 only say Enter activates, and the no-repeat rule is written only for DropdownMenu, ContextMenu and Table row activation. - An engineering owner decides whether
Button, andIconButtonandToggleButtonthrough it (link mode included), takes that rule, which also makes Calendar, Carousel, Pagination and Stepper controls step once under a held Enter; they record it by commenting/approve-specfollowed by the full head commit SHA on this pull request (the author may do so if they are an engineering owner).
The fix itself does what it says: the three new cancel tests fail on main and pass here, and in Chromium a held Enter now toggles a ToggleButton once instead of ten times. CI has not run yet; a maintainer adds the ci:run label so it runs.
[Automated review]
|
Could a maintainer add the Verified locally at this head: the Button, ToggleButton and IconButton suites (228 tests), ButtonGroup, Toolbar, SegmentedControl and Pagination (317 tests), typecheck, and strict lint on the changed files. |
…eta#8944) A native button clicks on every auto-repeated Enter keydown, so a held Enter flipped a ToggleButton about 30 times a second and ran a Button's onClick or clickAction repeatedly. Button now cancels keydowns with repeat set for Enter after the caller's own onKeyDown has seen them.
8fa33be to
99a9e1c
Compare
|
Rebased onto current main (99a9e1c), which had generalized the disabled-key handler to Approval still waits on an engineering owner's decision that a held Enter is one press, and CI needs a maintainer to add |
There was a problem hiding this comment.
Approval waits on one engineering-owner decision; no code changes are requested.
- No current Button-family spec says a held Enter is one press:
component:ButtonAR2 andfamily:buttonsFR2 only say Enter activates, and the no-repeat rule is written only for DropdownMenu, ContextMenu and Table row activation. - An engineering owner decides whether
Button, andIconButtonandToggleButtonthrough it (link mode included), takes that rule, which also makes Calendar, Pagination, Carousel and Stepper controls step once under a held Enter; they record it by commenting/approve-specfollowed by the full head commit SHA on this pull request (the author may do so if they are an engineering owner).
After the rebase the fix still does what it says: the three new cancel tests fail on main and pass here, and in a real browser a held Enter now toggles a ToggleButton once instead of ten times. One non-blocking suggestion, a shorter code comment, is inline. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.
[Automated review]
| // Otherwise a held Enter is one press: a native button clicks on every | ||
| // auto-repeated keydown, so the repeats are cancelled after the caller has | ||
| // seen them. |
There was a problem hiding this comment.
Non-blocking (comment style): this sentence runs 26 words, uses the passive "the repeats are cancelled", and carries two topics. A shorter version that keeps only the browser quirk and the reason:
// A native button clicks on each auto-repeated Enter keydown. Cancel each
// repeat after the caller's handler, so a held Enter is one press.
Fixes #8944
User impact
Holding Enter on a
Button,IconButtonorToggleButtonactivates it once per keyboard auto-repeat, because a native<button>clicks on every repeated Enter keydown. A held Enter on aToggleButtonflips it about 30 times a second and leaves it in whichever state the key comes up on. On aButtonit runsonClickor an interruptibleclickActionmany times, which can add rows, step a counter or send a message more than once.Problem and solution fit
Buttonhad no check forKeyboardEvent.repeat. Its only key handler ran when the button was aria-disabled, and the click path cannot tell a repeat from a press.IconButtonandToggleButtonrenderButton, so one change covers all three.Buttonnow cancels an Enter keydown withrepeatset, after the caller's ownonKeyDownhas seen it.Expected behavior and authority
A held key is one press. Astryx already rejects auto-repeat activation elsewhere:
DropdownMenuandContextMenuignore repeated keys, and Table activation states "Keyboard auto-repeat never activates" inuseTableActivation.spec.mdFR8. This applies the same rule to the Button family.Smallest restoration
Only
Button.tsxchanges. The key handler is always attached now (it was attached only while aria-disabled), and the aria-disabled behavior is unchanged: Enter and Space are still suppressed and other keys still reach the caller. For a button that is not aria-disabled the handler calls the caller'sonKeyDownfirst, then cancels an Enter repeat. Space is untouched because a native button clicks on its key-up. No new props or API.Evidence
<button>(Playwright, one key-down then nine auto-repeated key-downs, then the key-up) produced 10 clicks.onkeydownthat callspreventDefault()on an Enter repeat produced 1 click.onKeyDownstill receives every keydown including the repeats, a non-Enter repeat such as ArrowDown is not cancelled, and the aria-disabled tests for Enter and Space still pass.Button.test.tsxandToggleButton.test.tsx. Three of them (the button, the link and the ToggleButton cases) fail on currentmainand pass here.Scope
Testing
npx vitest run packages/core/src/Button packages/core/src/ToggleButton packages/core/src/IconButton: 6 files, 228 tests pass.ButtonGroup,Toolbar,SegmentedControlandPagination: 7 files, 317 tests pass.npx tsc --noEmit -p packages/core/tsconfig.jsonand strict ESLint on the changed files: clean.<button>with the same guard, not against the built Astryx component, so it shows the mechanism (cancelling the repeat keydown stops the repeated click). The unit tests exercise the real component throughfireEvent, whose return value is false when the keydown's default was prevented.