WordPress/gutenberg

Make tooltips dismissable

Open

#15145 opened on Apr 24, 2019

View on GitHub
 (1 comment) (2 reactions) (0 assignees)JavaScript (9,607 stars) (3,893 forks)batch import
Good First Issue[Focus] Accessibility (a11y)

Description

Opening this issue to associate it to the pending PR #8147

As noted in #8033, in some edge cases the Gutenberg tooltips can overlay other buttons in the user interface. Also, according to the Web Content Accessibility Guidelines, tooltips need to be dismissable.

WCAG reference: Success Criterion 1.4.13 Content on Hover or Focus https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus https://www.w3.org/WAI/WCAG21/Understanding/content-on-hover-or-focus.html

There are 3 items to address to meet the requirement:

  • dismissable
  • hoverable
  • persistent

#8033 made the tooltips persist but the "dismissable" part is missing. The guideline requires "a mechanism to dismiss the additional content without moving pointer hover or keyboard focus", and the suggestion is "by pressing Escape".

The correct behavior was visible, for example, on the previous Gmail interface (you can still revert Gmail to "Classic Gmail" for testing):

  • hover on a button, the tooltip appears and persists
  • don't move the mouse
  • press Escape: the tooltip disappears

Not sure how to implement such a "global" Escape key behavior for all the tooltips in the UI.

For now, #8147 addresses just a first part by making use of onMouseDown:

  • makes the tooltips dismissable when clicking on them
  • prevents the click event on the tooltip to be passed to the button and trigger the associated action
  • adds a cursor: default style to the tooltip

Anyone willing to continue work on #8147 is very welcome!

Contributor guide