WordPress/gutenberg

Make tooltips dismissable

開放

#15,145 建立於 2019年4月24日

 (5 則留言) (2 個反應) (0 位負責人)JavaScript (3,893 個分叉)batch import
Good First Issue[Focus] Accessibility (a11y)

倉庫指標

星標
 (9,607 顆星)
PR 合併指標
 (平均合併 12天 18小時) (30 天內合併 509 個 PR)

描述

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!

貢獻者指南