user-event
user-event copied to clipboard
Radio inputs - fix arrow button functionality
What:
This PR fixes a bug where keyboard navigation through radio inputs did not work as expected (#1048).
Why:
This gives us true-to-life outputs when radio inputs are tested with the keyboard.
How:
-
Sending correct directions for up/down arrows - Based on native browser interactions plus this W3C spec for a widget based on radio inputs, Down/Right arrows should move us forward in the group, and Up/Left should move us back. I adjusted
keydown.ts
to send the correct directions for Down and Up key events. -
Only advancing one element at a time - The initial behavior seemed to move us through every valid radio input within a group. I've updated
radio.ts
so that we only move forwards or backwards by 1 valid radio input.
Checklist:
- [x] Documentation
- [x] Tests
- [x] Ready to be merged
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit cd07f09ac5b3530dbd8765774d8ca5a2c66eaa8d:
Sandbox | Source |
---|---|
userEvent-dom | Configuration |
userEvent-react | Configuration |
@ph-fritsche Please let me know if I should do anything to address the failing linting job. I would volunteer to make the fixes, but the issues are all in files that this PR didn't change.
If it helps in debugging, I get these linting issues when running npm run lint
locally on vgpena:pr/radio-keyboard and on testing-library:main, even though the linting job is passing in CI on testing-library:main
.
Thanks!
@ph-fritsche @vgpena I'm willing to work on this. If there is something I can do to push this forward just let me know
Any update for this? I want the bug to be fixed, so I would create another PR if you don't finish this.
Just saw this PR, looks like it's the same as the implementation I had, but I added an additional test to ensure that aria-disabled was still selectable.
https://github.com/testing-library/user-event/pull/1199
Happy for either fix to go through, but would be great to an eye on one of these from a maintainer. Is there anything blocking this particular PR at this point?
@ph-fritsche Is there anything blocking this PR still? Would be happy to make any edits, looks like this is just blocked on maintainer review.