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

Make disabled components focusable and hoverable #4585

Open
9 of 10 tasks
rolfsmeds opened this issue Sep 13, 2022 · 9 comments · May be fixed by vaadin/docs#4077
Open
9 of 10 tasks

Make disabled components focusable and hoverable #4585

rolfsmeds opened this issue Sep 13, 2022 · 9 comments · May be fixed by vaadin/docs#4077
Labels
a11y Accessibility issue enhancement New feature or request vaadin-tooltip

Comments

@rolfsmeds
Copy link
Contributor

What is the problem?

Disabled components currently have tabindex="-1", which removes them from the keyboard tab order, making them effectively un-focusable, and, as a side-effect, makes them effectively invisible to assistive technologies, thus bad for accessibility.

The disabled state also applies the pointer-events:none css property, which disables hover/mouseover based functionality such as tooltips. This is unfortunate especially as tooltips are a convenient way to inform the user why a component (e.g. a Button) is disabled. Removing this would require some additional css and js to handle the pointer-inertness of the component, but enabled tooltip usage.

Ideally this behavior would be configurable via a feature flag or a global property, so that applications for which it is desired to keep the current behavior could easily revert back to it.

Browsers

  • Chrome
  • Firefox
  • Safari
  • Safari on iOS
  • Edge

Screen Readers

  • None
  • NVDA
  • JAWS
  • VoiceOver on MacOS
  • VoiceOver on iOS
@rolfsmeds rolfsmeds added the a11y Accessibility issue label Sep 13, 2022
@knoobie
Copy link
Contributor

knoobie commented Sep 13, 2022

aria-disabled='true' could still be applied, which could be used as styling attribute and helps sreenreaders to know that this button is disabled. See e.g. Aria-disabled or How can I make a disabled button focusable, clickable, in general “interact-able”?

@rolfsmeds
Copy link
Contributor Author

Actually, unless I'm mistaken, we don't even have to remove the disabled attribute on the root element, as that has no effect on custom elements.

@web-padawan
Copy link
Member

Yes, we still need to keep disabled for styling and to ensure that e.g. setDisableOnClick(true) works as expected.
Also, we need to ensure that click events would not fire on disabled elements (maybe stop propagation for them).

@web-padawan
Copy link
Member

This issue would also be relevant for vaadin-tooltip as users might want to use it with disabled components:

The current workaround would be to wrap disabled component in a different element and set a tooltip for it.

@TatuLund
Copy link
Contributor

Just noting, that e.g. with buttons, it is possible to override the style using this in styles.css

vaadin-button[disabled] {
   pointer-events: auto;
}

@jouni
Copy link
Member

jouni commented Mar 16, 2023

it is possible to override the style using this in styles.css

An unwanted side-effect of that is that disabled button will then apply :hover and [active] styles, making them appear clickable.

@enver-haase
Copy link
Contributor

Just noting, that e.g. with buttons, it is possible to override the style using this in styles.css

Horrible UX (open/close flicker) with Select as well, so not a generically viable solution.

@enver-haase
Copy link
Contributor

Having said that. @TatuLund 's idea seems to work really well for one customer of mine. They claim they have tested a huge range of components with the events enabled along the implementation above. Only Select, for them, exposed an unwanted flicker. Maybe an implementation with pointer events being enabled is not as hard as we think (bar the testing).

@rolfsmeds
Copy link
Contributor Author

From what I can tell, the following would need to be done to make disabled buttons focusable and hoverable:

  • Introduce a feature flag for enabling tabindex and pointer-events changes below to avoid affecting existing applications (other changes should be safe without flag)
  • Remove tabindex="-1" allowing the button to receive focus
  • Remove pointer-events:none allowing the button to react to hover
  • Suppress active state styling when disabled
  • Set cursor: not-allowed cursor when disabled
  • Add logic to prevent pointer and keyboard clicks when disabled
  • Add documentation (Button docs page, setEnabled javadoc and disabled jsdoc)
  • Test on big 3 screen readers that the disabled buttons are focusable and correctly announced as disabled
  • Test that Tooltips and focus/hover-triggered Popovers work normally on disabled buttons

The disabled attribute can be retained, as it should not affect focusability or screen reader accessibility on its own (since the button is a custom element).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Accessibility issue enhancement New feature or request vaadin-tooltip
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants