react-component / react-component/tooltip

Improve Keyboard Accessibility

Open
#191 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
944
Forks
199
Avg merge
19h 1m
Merged PRs (30d)
3

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the tooltip rendering and focus/blur handling, then reproduce keyboard focus moving into a visible tooltip; done means the tooltip is rendered beside its trigger and remains open while focus stays within the component.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
accessibility, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.