Skip to content

Improve Keyboard Accessibility #191

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

Open
Neurrone opened this issue Jul 6, 2019 · 0 comments
Open

Improve Keyboard Accessibility #191

Neurrone opened this issue Jul 6, 2019 · 0 comments

Comments

@Neurrone
Copy link

Neurrone commented Jul 6, 2019

problem

  1. By default, the tooltip's contents is rendered at the bottom of the DOM, so that it is not practical to use the keyboard to access the contents of the tooltip (e.g, to activate navigation links on a menu). This also makes it difficult for screen reader users to read the contents of the tooltip once it is visible, because it is not next to the triggering element.
  2. There is an option to display the tooltip when the element gains focus. However, this does not work at all in practice because when keyboard focus moves to an element inside the displayed tooltip, the tooltip closes.

Proposed solution

We're using this library at work, and have implemented the following workaround. If there's interest, I'll be happy to submit an MR.

  1. Instead of by default rendering the tooltip contents by appending to the end of the DOM, render it next to the triggering element. We worked around this by providing a node next to the triggering element with getTooltipContainer.

  2. Listen for blur events, and only hide the tooltip if the related target is not a child of the component's render tree (i.e, if focus is being moved outside the tooltip). Working around this from outside the library was more complex, because we had to set the visible prop explicitly, ensuring that it would react correctly to both keyboard focus and mouse hover events.

shc023 pushed a commit to shc023/tooltip that referenced this issue Jul 31, 2021
* fix: Motion state record (react-component#188)

* fix: Motion state record

* update test case

* fix: Motion state record
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant