Skip to content

fix: delegate checkbox/radio/switch label keydown to native inputs#9972

Open
nami8824 wants to merge 5 commits into
adobe:mainfrom
nami8824:fix/native-input-keydown-checkbox-radio-switch
Open

fix: delegate checkbox/radio/switch label keydown to native inputs#9972
nami8824 wants to merge 5 commits into
adobe:mainfrom
nami8824:fix/native-input-keydown-checkbox-radio-switch

Conversation

@nami8824

@nami8824 nami8824 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Closes #6235

  • usePress's onKeyDown was preventing default on 'Enter' key for input's of type radio and checkbox

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Go to a form with a radio/checkbox/switch and the ability to implicitly submit, fill out the form and hit Enter from one of those three components.

🧢 Your Project:

@github-actions github-actions Bot added the RAC label Apr 23, 2026

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One big thing to note, Enter can no longer be used to toggle a switch or checkbox with this PR. It could be argued that Space should be the only way to do it as that is how native inputs work, but we've had this behaviour for 6+ years, so I don't know if we can change it lightly.

Comment thread packages/react-aria/src/toggle/useToggle.ts Outdated
Comment thread packages/react-aria/src/radio/useRadio.ts Outdated
@nami8824

Copy link
Copy Markdown
Contributor Author

One big thing to note, Enter can no longer be used to toggle a switch or checkbox with this PR. It could be argued that Space should be the only way to do it as that is how native inputs work, but we've had this behaviour for 6+ years, so I don't know if we can change it lightly.

I hadn't noticed this impact.

I think disabling Enter-to-toggle is necessary to properly address this issue, because allowing Enter to both toggle a checkbox/radio/switch and submit a form at the same time feels like unexpected behavior.

How should Enter be handled for these elements...?

@snowystinger

Copy link
Copy Markdown
Member

Nothing yet, lets wait for more opinions from the team

@github-actions github-actions Bot removed the RAC label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event Bubbling Issue with Radio Component in Form Navigation

2 participants