Skip to content
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

Radio inputs - fix arrow button functionality #1049

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

Conversation

vgpena
Copy link

@vgpena vgpena commented Aug 31, 2022

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:

  • Documentation
  • Tests
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 31, 2022

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

Sandbox Source
userEvent-dom Configuration
userEvent-react Configuration

Copy link
Member

@ph-fritsche ph-fritsche left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to contribute to this library ❤️

src/event/radio.ts Outdated Show resolved Hide resolved
tests/event/behavior/keydown.ts Outdated Show resolved Hide resolved
Violet Peña and others added 2 commits September 1, 2022 11:05
@vgpena
Copy link
Author

vgpena commented Sep 1, 2022

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

@filipw01
Copy link

filipw01 commented Dec 1, 2022

@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

@tnyo43
Copy link

tnyo43 commented May 25, 2023

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

@joshferrell
Copy link

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.

#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
Copy link

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

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.

Radio inputs - using Arrow keys to navigate focuses incorrect inputs
5 participants