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

fix(Indeterminate Checkbox): Fixed issue with voice over not recognizing the mixed state when using keyboard navigation. #1652

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

chris-cedrone-cengage
Copy link
Collaborator

@chris-cedrone-cengage chris-cedrone-cengage commented Jan 31, 2025

Closes #1231

🐒 What I did 🐒

Restructured DOM to recognize the "mixed" state when Voice Over tabs over indeterminate checkboxes

πŸ“Ί Screenshots: πŸ“Ί

Example

βœ… Checklist βœ…

  • changeset has been added
  • Pull request description is descriptive
  • [N/A] I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes
  • [N/A] I have added tests that prove my fix is effective or that my feature works

🐎 How to test 🐎

  1. Open Storybook
  2. Go to Indeterminate Checkbox
  3. Open Voice Over
  4. Navigate to a Indeterminate Checkbox with keyboard
  5. Verify "mixed" state is probably read
  6. Go to Datagrid > Selectable
  7. Verify Indeterminate Checkbox works appropriately here
  8. Go to TreeView > First Item Branch
  9. Verify Indeterminate Checkbox works appropriately here

Copy link

changeset-bot bot commented Jan 31, 2025

πŸ¦‹ Changeset detected

Latest commit: bace366

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
react-magma-dom Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Copy link
Contributor

@chris-cedrone-cengage chris-cedrone-cengage requested review from nikitaorliak-cengage and silvalaura and removed request for a team and silvalaura January 31, 2025 19:37
@moathabuhamad-cengage
Copy link
Collaborator

it does read mixed, I was able to check the disabled checkbox in the storybook using my keyboard

image

) : isChecked ? (
<CheckBoxIcon size={theme.iconSizes.medium} />
<div
tabIndex={!disabled && 0}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about this tabindex here. It's changing the keyboard navigation behavior in TreeView which we don't want. Speaking of which, we should note in the testing notes to consider TreeView and DataGrid

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed the div and moved these attributes to StyledFakeInput.

<div
tabIndex={!disabled && 0}
role="checkbox"
aria-checked="mixed"
Copy link
Collaborator

Choose a reason for hiding this comment

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

When we add this, we now have an input with aria-checked mixed AND a div with it. Is this okay? How do other systems handle this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, this mixed status is hardcoded so even when it becomes checked, mixed is still in the dom.

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Copy link
Contributor

github-actions bot commented Feb 4, 2025

Copy link
Collaborator

@silvalaura silvalaura left a comment

Choose a reason for hiding this comment

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

  1. Having tabIndex here still breaks the keyboard navigation in TreeView. With TreeView, we expect Tab key moves to the tree and then out of the tree and the tree should be navigated with up and down arrows.

  2. The focus around the indeterminate checkbox looks weird/different to the focus around regular checkboxes
    image
    image

  3. Have you found a good example in the wild that does what we are trying to do? That will help us ensure we are doing this the right way.

@@ -172,6 +185,10 @@ export const IndeterminateCheckbox = React.forwardRef<
style={inputStyle}
theme={theme}
aria-hidden="true"
tabIndex={0}
role="checkbox"
aria-checked={isIndeterminate ? 'mixed' : isChecked}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it okay to have aria-checked twice? If it is, we can copy line 153 aria-checked={ariaCheckedValue}.
We have type="checkbox" on the hidden input so I worry this is repetitive??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants