Skip to content

Fix: Prevent Checkbox and Radio from unexpectedly calling onBlur when focus moves within the component #8108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

uniqueeest
Copy link

Closes #8045

✅ 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:

  • Verify that Checkbox and Radio now correctly trigger onBlur and onFocus only when focus moves in/out of the component, not when moving internally between label and input.
  • Use keyboard (Tab) and mouse (click) to test focus and blur behavior:
    • onBlur should not be called when clicking from <label> to internal <input>.
    • onBlur should be called when focus leaves the component.
  • Confirm that all relevant tests pass:
    • should support focus ring
    • should support focus events
    • should not call onBlur when focus stays within label
    • should call onBlur when focus leaves the label

🧢 Your Project:

@uniqueeest uniqueeest marked this pull request as draft April 17, 2025 14:33
@uniqueeest uniqueeest marked this pull request as ready for review April 17, 2025 14:51
@uniqueeest
Copy link
Author

@snowystinger How do I pass that test? A few tests fail because of the focus on the label.

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.

RAC Checkbox and Radio unexpectedly call onBlur
1 participant