user-event icon indicating copy to clipboard operation
user-event copied to clipboard

Radio inputs - fix arrow button functionality

Open vgpena opened this issue 2 years ago • 6 comments

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:

  1. 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.
  2. 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

vgpena avatar Aug 31 '22 21:08 vgpena

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

codesandbox-ci[bot] avatar Aug 31 '22 21:08 codesandbox-ci[bot]

@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!

vgpena avatar Sep 01 '22 19:09 vgpena

@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

filipw01 avatar Dec 01 '22 16:12 filipw01

Any update for this? I want the bug to be fixed, so I would create another PR if you don't finish this.

tnyo43 avatar May 25 '23 13:05 tnyo43

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?

joshferrell avatar Feb 28 '24 00:02 joshferrell

@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.

joshferrell avatar Mar 15 '24 23:03 joshferrell