Skip to content

fix(uui-radio): keyboard navigation does not work as intended #870

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

Merged
merged 21 commits into from
Jul 25, 2024

Conversation

JesmoDev
Copy link
Contributor

@JesmoDev JesmoDev commented Jul 24, 2024

FIXES: #853

The radio button now always sets focus on the native input. This means that we can remove all aria attributes as they are automatically provided by the native radio input.

The radio group now emulates native radio group behavior.

Fixes following issues:

  • Have to press ArrowDown twice to select next radio while at the first radio
  • Pressing ArrowUp while at the first radio throws errors and does not wrap to the last radio as it should
  • Unable to keyboard navigate onto a single radio or into a radio group with no preselected radio
  • Unreliable keyboard navigation in and out of radio groups

I've also cleaned up both components a lot to align them better with our new coding practises.
You can use Semantic Diff to get a better overview of the actual changes: https://app.semanticdiff.com/gh/umbraco/Umbraco.UI/pull/870/changes#packages/uui-radio/lib/uui-radio-group.element.ts

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • If my change requires a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

1 similar comment
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

1 similar comment
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

@JesmoDev JesmoDev marked this pull request as ready for review July 24, 2024 15:39
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

@JesmoDev JesmoDev marked this pull request as draft July 25, 2024 08:16
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

@JesmoDev JesmoDev marked this pull request as ready for review July 25, 2024 08:23
@iOvergaard iOvergaard added the bug Something isn't working label Jul 25, 2024
@iOvergaard iOvergaard changed the title Bugfix: UUIRadio Accessibility fix(uui-radio): keyboard navigation does not work as intended Jul 25, 2024
Copy link
Contributor

@iOvergaard iOvergaard left a comment

Choose a reason for hiding this comment

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

This aaaaalmost works. I tested in Storybook and there is just one case: When a group already has a value, and you tab into it, you invariably end up on the first element, and if that element is not selected, and you move with the keyboard, you end up selecting the next element after that and so on.

I think before it detected if a value was already preselected, it would put tabindex -1 on the others.

https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net/?path=/story/uui-radio--group-with-start-value

Copy link

Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://delightful-beach-055ecb503-870.westeurope.azurestaticapps.net

Copy link
Contributor

@iOvergaard iOvergaard left a comment

Choose a reason for hiding this comment

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

LGTM

@iOvergaard iOvergaard merged commit 46e93ca into v1/contrib Jul 25, 2024
9 of 10 checks passed
@iOvergaard iOvergaard deleted the v1/bugfix/radio-accessibility branch July 25, 2024 14:21
iOvergaard pushed a commit that referenced this pull request Jul 25, 2024
* remove tabindex

* fix wrapping keyboard nav

* Improve keyboard navigation by emulating native radio group behavior

* remove unused code

* fix double keypress issue

* cleanup

* fix selection bug

* rename function

* change focus outline functionality to pure css

* remove aria hidden as it is not needed anymore

* remove redundant get,set

* cleanup radio

* cleanup

* fix findRadio function to fix focus issues

* remove keypress eventListener

* Fix pre checked radios

* fix test to use same keydown event as the component

* make sonar happy

* fix tab navigation when there is a pre-checked radio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid aria-checked attribute for radiobutton
3 participants