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

[Checkbox, Menu, Switch] Audit focus states on disabled components #734

Merged

Conversation

onehanddev
Copy link
Contributor

@onehanddev onehanddev commented Oct 13, 2024

Changes -

  • Removed focusableWhenDisabled from Menu trigger
  • The disabled prop has been passed down to the component renderer, allowing the Checkbox and Switch components to appropriately reflect their disabled state in the DOM elements.

[] I have followed (at least) the PR section of the contributing guide.

closes #656

hakim-toptal and others added 3 commits October 13, 2024 13:05
- Removed focusableWhenDisabled from Menu trigger
- Passed down disabled prop to the component renderer to enable the disabled state to the DOM element
@mui-bot
Copy link

mui-bot commented Oct 13, 2024

Netlify deploy preview

https://deploy-preview-734--base-ui.netlify.app/

Generated by 🚫 dangerJS against 238a110

@onehanddev onehanddev changed the title Audit focus states disabled components Audit focus states on disabled components Oct 13, 2024
@onehanddev onehanddev marked this pull request as ready for review October 13, 2024 08:35
Copy link
Member

@michaldudak michaldudak 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 working on this! With a few tweaks this will be good to merge.

@@ -98,6 +98,7 @@ const CheckboxRoot = React.forwardRef(function CheckboxRoot(
extraProps: {
...otherProps,
...otherGroupProps,
disabled,
Copy link
Member

Choose a reason for hiding this comment

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

Instead of passing disabled here, it should be set by useCheckboxRoot's getButtonProps. You can remove aria-disabled and have just disabled prop returned from there.
Same with the Switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing that out! 🙏 I’ve updated the code.
Please let me know if there are any further changes needed. 😊

Copy link
Contributor Author

@onehanddev onehanddev Oct 23, 2024

Choose a reason for hiding this comment

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

It appears that removing aria-disabled is causing CircleCI’s browser tests to fail. Do you think we should reintroduce aria-disabled alongside the disabled prop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the various a11y resources, we are not required to use aria-disabled if we already are using native form elements like button with appropriate roles like switch or checkbox. what do you think @michaldudak ?

Copy link
Member

Choose a reason for hiding this comment

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

No, having just the disabled attribute is enough. Using both disabled and aria-disabled is redundant and may trigger warnings in some a11y validators.
IMO the way to go would be updating the tests to expect the disabled attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michaldudak I have fixed the tests, Please review it again. Thanks !

@michaldudak michaldudak added component: switch This is the name of the generic UI component, not the React module! component: menu This is the name of the generic UI component, not the React module! component: checkbox This is the name of the generic UI component, not the React module! labels Oct 28, 2024
Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for your contribution!

@michaldudak michaldudak changed the title Audit focus states on disabled components [Checkbox, Menu, Switch] Audit focus states on disabled components Oct 28, 2024
@michaldudak michaldudak merged commit 7f8705d into mui:master Oct 28, 2024
21 checks passed
atomiks pushed a commit to atomiks/base-ui that referenced this pull request Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y component: checkbox This is the name of the generic UI component, not the React module! component: menu This is the name of the generic UI component, not the React module! component: switch This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Audit focusableWhenDisabled
5 participants