fix: avoid duplicate Space presses on form buttons - #10694
Open
minwookshin wants to merge 1 commit into
Open
minwookshin wants to merge 1 commit into
minwookshin wants to merge 1 commit into
Conversation
snowystinger
reviewed
Oct 1, 2026
| // Native controls may click after Space keyup. Keep their default action, but | ||
| // don't handle that click as another press. Clear this even if the click is canceled. | ||
| state.ignoreEmulatedMouseEvents = true; | ||
| setTimeout(() => { |
Member
There was a problem hiding this comment.
can we clear it any other way that doesn't rely on timeouts? if not, we'll want to explore other approaches before choosing this one
Contributor
Author
There was a problem hiding this comment.
Tested microtask cleanup: submit/reset still double-fire in Chromium and WebKit. Clearing only on click swallows the next virtual activation after a canceled keyup in all three browsers; would you prefer exploring dispatch from the native click instead?
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.
Closes #10658
Space should activate a form button once while preserving its native submit/reset behavior.
usePresscurrently handles the keyup and then treats the browser's following click as a second, virtual press.Keep the existing emulated-click guard set through that native click, and clear it on the next task even when the browser click is canceled. Browser tests cover repeated Space presses, Enter, submit/reset defaults, and subsequent mouse/programmatic activation.
AI-assisted implementation and verification with Codex, following AGENTS.md and the contribution guidance.
✅ Pull Request Checklist:
📝 Test Instructions:
Run
yarn vitest run --config=vitest.browser.config.ts packages/react-aria-components/test/Button.browser.test.tsx. The submit/reset Space cases fail before the fix in Chromium, Firefox, and WebKit; all 12 cases pass afterward.Also verified:
yarn lint, including formatting, types, constraints, and package checks.Keyboard, mouse, and programmatic clicks are covered. Screen-reader interaction was not manually tested.
🧢 Your Project:
Independent open-source contribution.