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

Merged
merged 5 commits into from
Jan 21, 2025

Conversation

vgpena
Copy link
Contributor

@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

Sorry, something went wrong.

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

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 ❤️

@vgpena
Copy link
Contributor 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
Contributor

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
Contributor

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

Violet Peña and others added 4 commits January 16, 2025 18:34
Co-authored-by: Philipp Fritsche <ph.fritsche@gmail.com>
Adds an additional test to ensure that aria-disabled is still focusable
@ph-fritsche ph-fritsche merged commit bf8111c into testing-library:main Jan 21, 2025
3 checks passed
Copy link

🎉 This PR is included in version 14.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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.

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