Skip to content

Add an accessible tooltip mechanism, and use it for the "Remember Me" login tooltip ( #55343 & #51006 )#12212

Open
rutviksavsani wants to merge 3 commits into
WordPress:trunkfrom
rutviksavsani:add/accessible-tooltip-remember-me
Open

Add an accessible tooltip mechanism, and use it for the "Remember Me" login tooltip ( #55343 & #51006 )#12212
rutviksavsani wants to merge 3 commits into
WordPress:trunkfrom
rutviksavsani:add/accessible-tooltip-remember-me

Conversation

@rutviksavsani

Copy link
Copy Markdown

Trac tickets:

Summary

#55343 needs a tooltip next to the Remember Me checkbox on wp-login.php, and the
ticket history makes it dependent on #51006 (a reusable accessible-tooltip
mechanism). This PR resolves both together:

  1. Adds a small, reusable, accessible tooltip mechanism — wp_get_tooltip()
    plus a wp-tooltip stylesheet — built on the native Popover API + CSS anchor
    positioning
    , matching the final direction agreed in #51006.
  2. Uses that mechanism to add the requested "Remember Me" tooltip on the login form, with
    filterable copy.

Approach

  • Native Popover API drives all interaction — open/toggle, Esc, light-dismiss, focus
    return — so there is no JavaScript to ship or maintain.
  • CSS anchor positioning (position-area: top) places the bubble above its toggle using the
    popover's implicit anchor, so multiple tooltips on one page each anchor to their own toggle
    with no per-instance IDs. Gated behind @supports (anchor-name: --a).
  • Visual treatment (bubble, border, shadow, bordered-triangle arrow) mirrors the existing admin
    pointer (wp-pointer.css).
  • wp_get_tooltip( $content, $args ) returns the markup (content-first signature, mirroring
    wp_get_admin_notice()); the login template echoes it. Single function, return-only — the
    same shape as wp_required_field_indicator().
  • Tooltip copy on login is filterable via login_remember_me_help_text (return '' to remove).

Accessibility

Implements the accessible-tooltip specification from #51006 (comment #15) in full, and
targets WCAG 2.2:

  • No role="tooltip", aria-haspopup, or aria-live.
  • Supplemental content is associated with the trigger via aria-describedby pointing to a
    text-only element, so the description is the help sentence and nothing else.
  • Focus does not move into the tooltip on open.
  • Dismissable via Esc, click-outside, and a visible close button that returns focus to the
    trigger without re-opening it. Esc works in every engine.
  • Close button and toggle are both 24×24 px — WCAG 2.2 2.5.8 Target Size (Minimum).
  • Bubble opens above the toggle, so the focused control is never covered.
  • Visible focus ring using the admin theme colour, plus a transparent outline so focus stays
    visible in Windows High Contrast / forced-colors mode (2.4.7).
  • Plain text only, no timeout, interactive source, no title attribute.
  • Triggers and labels are translatable.

Files changed

File Change
src/wp-includes/general-template.php New wp_get_tooltip() — returns accessible tooltip markup.
src/wp-admin/css/wp-tooltip.css New reusable wp-tooltip component stylesheet.
src/wp-includes/script-loader.php Registers the wp-tooltip style and makes the login styles depend on it.
src/wp-login.php Adds the filterable help text and renders the tooltip via wp_get_tooltip().
tests/phpunit/tests/general/wpGetTooltip.php New unit tests for wp_get_tooltip().

Testing instructions

  1. open WordPress admin login screen /wp-login.php.
  2. A ? help icon appears after "Remember Me". Click it (or focus + Enter) → tooltip opens with
    the security copy.
  3. Dismiss via the × button, Esc, or clicking outside.
  4. Keyboard: Tab to the icon → Enter opens → Esc closes and focus returns to the icon.
  5. Screen reader: focusing the icon announces the button name followed by the help sentence
    (not the word "Close"), and the bubble is not announced as a "tooltip".
  6. Developer filter:
    add_filter( 'login_remember_me_help_text', fn() => 'Custom copy.' );
    add_filter( 'login_remember_me_help_text', '__return_empty_string' ); // removes the tooltip
  7. Unit tests: npm run test:php -- --filter Tests_General_wpGetTooltip (7 tests).

Screenshots

Tooltip open, captured on each real engine:

Chromium:
xbrowser-chromium

Safari / W
xbrowser-webkit
ebKit
:

Firefox :
Screenshot 2026-06-18 at 12 54 38 PM


Use of AI Tools

AI assistance: Yes
Tool: Claude Code
Model: Opus 4.8 with 1M context
Used for: Initial code skeleton and unit tests; final implementation and tests were reviewed and edited by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Add a reusable, accessible tooltip mechanism built on the native Popover
API and CSS anchor positioning. wp_get_tooltip() returns a help toggle and
an associated popover; the content is linked to the toggle with
aria-describedby and is dismissable via Escape, a click outside, or a
visible close button.

Includes the wp-tooltip stylesheet and unit tests.

See #51006.
Add a help tooltip next to the "Remember Me" checkbox on the login form,
explaining the option and its security implications. The text is
filterable via the login_remember_me_help_text filter.

Built using wp_get_tooltip().

See #55343.
@github-actions

Copy link
Copy Markdown

Hi there! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props rutviksavsani.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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

Successfully merging this pull request may close these issues.

1 participant