Make WordPress Core

Opened 4 months ago

Closed 4 weeks ago

#65633 closed enhancement (fixed)

Toggle tips should also display tooltips

Reported by: joedolson Owned by: joedolson
Priority: normal Milestone: 7.2
Component: General Version: 7.1
Severity: normal Keywords: has-patch has-unit-tests commit
Cc: Focuses: ui, accessibility, javascript

Description

With no visible text label, a toggle tip needs to also display a tooltip to expose its accessible name.

This was deemed a nice to have in #51006, but not critical for initial implementation, as it adds significant complexity.

Attachments (7)

65633-test-desktop-1-hover.png​ (586.9 KB ) - added by D SIGNED 7 weeks ago.
65633-test-desktop-2-focus.png​ (587.6 KB ) - added by D SIGNED 7 weeks ago.
65633-test-desktop-3-click.png​ (625.4 KB ) - added by D SIGNED 7 weeks ago.
65633-test-mobile-1-long-touch.png​ (228.9 KB ) - added by D SIGNED 7 weeks ago.
65633-test-mobile-2-click.png​ (278.7 KB ) - added by D SIGNED 7 weeks ago.
65633-test-tablet-1-long-touch.png​ (226.2 KB ) - added by D SIGNED 7 weeks ago.
65633-test-tablet-2-click.png​ (259.6 KB ) - added by D SIGNED 7 weeks ago.

Change History (26)

#1 @joedolson
4 months ago

  • Focuses ui javascript added

#2 @iamchitti
4 months ago

A toggle tip (as returned by wp_get_toggletip()) renders an icon-only toggle button with no visible text label. Its accessible name comes solely from aria-label, so it is exposed to assistive technologies but not to sighted mouse or keyboard users, who get no on-hover or on-focus indication of what the button does.

By contrast, a tooltip already shows a hover/focus popover that surfaces its accessible name. This ticket brings the same affordance to toggle tips, which was deemed a "nice to have" and deferred in #51006.

Proposed fix

Give the toggle button its own hover/focus hint that visually exposes the same accessible name, reusing the existing tooltip presentation. The hint is aria-hidden, since the button already announces its name via aria-label, so it stays purely visual and avoids a duplicate announcement. It is suppressed while the toggle tip dialog itself is open, so the two never overlap.

Behaviour is unchanged for the tooltip type and for assistive technologies.

I'll open a PR shortly.

This ticket was mentioned in ​PR #12532 on ​WordPress/wordpress-develop by ​@iamchitti.


4 months ago
#3

  • Keywords has-patch has-unit-tests added

## Trac ticket

https://core.trac.wordpress.org/ticket/65633

## Summary

With no visible text label, a toggle tip's toggle button (from wp_get_toggletip()) exposes its accessible name only through aria-label. That name reaches assistive technologies but is invisible to sighted mouse and keyboard users, who get no on-hover or on-focus indication of what the button does.

A tooltip already shows a hover/focus popover surfacing its accessible name. This PR brings the same affordance to toggle tips, which was deferred as a "nice to have" in #51006.

## Changes

  • wp-includes/general-template.php — the toggle tip markup now also outputs a hint popover carrying the button's label: `html <span popover="hint" id="{id}-hint" class="wp-tooltipbubble wp-tooltiphint" aria-hidden="true">

<span class="wp-tooltiptext">{label}</span>

</span>
It is aria-hidden on purpose — the button already announces its name via
aria-label, so the hint stays purely visual and avoids a duplicate announcement.

  • js/_enqueues/wp/wp-tooltip.js — shows the hint on mouseenter/focus and hides it on mouseleave/blur, mirroring the tooltip behaviour. The hint is suppressed while the toggle tip dialog is open, so the two never overlap.
  • wp-admin/css/wp-tooltip.css — .wp-tooltip__hint reuses the tooltip bubble styling.
  • tests/phpunit/tests/general/wpGetTooltip.php — added coverage for the hint markup, label duplication, and escaping.

Behaviour is unchanged for the tooltip type and for assistive technologies.

## Testing instructions

  1. Run npm run dev so the JS/CSS rebuild.
  2. Open wp-login.php and locate the ? help icon next to the "Remember Me" checkbox.
  3. Hover or Tab to the icon → a small "Help" tooltip appears after ~300ms; it hides on mouse-leave/blur.
  4. Click the icon → the help dialog opens and the hint disappears (no overlap). Hovering the icon while the dialog is open does not re-show the hint.
  5. Inspect the toggle button: it still has aria-label="Help", and the hint is aria-hidden="true" (a screen reader announces the name once, not twice).
  6. Run the tests: npm run test:php -- --filter Tests_General_wpGetTooltip.

## Screenshots

https://github.com/user-attachments/assets/39d440c4-8f9c-40f4-9536-1324dbd656bd

https://github.com/user-attachments/assets/14fef6b7-b185-4415-a14c-216cf94ff929

Related

This ticket was mentioned in ​Slack in #accessibility by joedolson. ​View the logs.


3 months ago

#5 @joedolson
3 months ago

  • Milestone Awaiting Review → 7.2
  • Owner set to joedolson
  • Status new → accepted

#6 @D SIGNED
7 weeks ago

# TEST #260917110403

› OS: MacOS 26.6.2
› APP: Arc 1.164.0 / Playground / DevTools device simulator
› Device : Desktop / iPad 13 / iPhone 16
› WP : 7.1-alpha-20260715.063422
› PHP : 7.4

Seems OK for me 👍️

Last edited 7 weeks ago by D SIGNED (previous) (diff)

​Sebastien-Gastard commented on ​PR #12532:


7 weeks ago
#7

Test ok on Firefox 156.0 - macOS
https://github.com/user-attachments/assets/1f0c53be-1ce6-4142-9839-3da5ca4ee2ab
https://github.com/user-attachments/assets/8abf4e70-f95e-4e7d-af17-a1d57b03446f

Also ok on iPhone safari (iOS 26.1)

​@audrasjb commented on ​PR #12532:


7 weeks ago
#8

There was a conflict between this PR and current trunk, I resolved it by accepting both changes.
Testing welcome!

​bdi-digital commented on ​PR #12532:


7 weeks ago
#9

Tooltip on toggle tip button is correctly displayed on the following configurations :

  • Mac OS / Voice Over 26.5.2 / Google Chrome 152
  • Android 17 / Talkback 17 / Google Chrome 153 (The visible label is displayed after tapping on close button on the tooltip)

Note :
On iOS / Voice Over 26.6.1 / Safari (The visible label is only displayed when Voice Over is activated). Otherwise it's not displayed.

​@audrasjb commented on ​PR #12532:


7 weeks ago
#10

Note: we have some type issues in various variables. The issues weren't here before but I think these tests didn't exist at the time the PR was proposed :)
Worth fixing these issue though

​@battelfred commented on ​PR #12532:


7 weeks ago
#12

Tooltip on toggle tip button is correctly displayed on the following configurations :
Windows / Chrome / 152
https://github.com/user-attachments/assets/52f93b23-d773-4fa2-a955-98cb7b5e0b58

​@iamchitti commented on ​PR #12532:


7 weeks ago
#13

Note: we have some type issues in various variables. The issues weren't here before but I think these tests didn't exist at the time the PR was proposed :)

Worth fixing these issue though

I'm taking a look at the failing actions.

​@iamchitti commented on ​PR #12532:


7 weeks ago
#14

JS type test is fixed. The remaining failing tests are also failing on trunk.

​@iamchitti commented on ​PR #12532:


7 weeks ago
#15

Would suggest re-testing, as the toggletip markup was briefly broken by a bad trunk merge.

This ticket was mentioned in ​Slack in #accessibility by joedolson. ​View the logs.


5 weeks ago

#17 @joedolson
4 weeks ago

  • Keywords commit added

​@joedolson commented on ​PR #12532:


4 weeks ago
#18

@bdi-digital I'm unable to locate a WordPress profile for you, so I'm not able to give you props during commit - if you have a WordPress profile, please link it to your Github profile using the guidance provided above! If you don't, I suggest creating one, so you can be properly credited for your contribution! Thank you!

#19 @joedolson
4 weeks ago

  • Resolution → fixed
  • Status accepted → closed

In 64292:

Admin: Add tooltip support to toggle tips.

Make the control's accessible name visible on hover and focus for toggle tip controls, so that keyboard and sighted users can discover the name of the control.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12532.

Props iamchitti, d-signed, audrasjb, joedolson, sgastard, nicoblandel, battelfred.
Fixes #65633.

Note: See TracTickets for help on using tickets.