Skip to content

Toolbar: Add access+w keyboard shortcut to toggle toolbar on frontend#39

Closed
apermo wants to merge 2 commits intotrunkfrom
feature/toolbar-toggle-shortcut
Closed

Toolbar: Add access+w keyboard shortcut to toggle toolbar on frontend#39
apermo wants to merge 2 commits intotrunkfrom
feature/toolbar-toggle-shortcut

Conversation

@apermo
Copy link
Copy Markdown
Owner

@apermo apermo commented Apr 7, 2026

Add a keyboard shortcut (Ctrl+Shift+F) to temporarily hide and show the toolbar on the frontend. This gives logged-in users a quick way to preview their site without the toolbar, without navigating to Profile settings or logging out.

Shortcut: Ctrl+Shift+F (all platforms)

Behavior

  • Toggle only: Hide the toolbar; press again to bring it back.
  • No persistence: Resets on page navigation — designed for quick previews.
  • Frontend only: Does not work in wp-admin (toolbar is not optional there, see #19685).
  • Smooth animation: 200ms CSS transition (slide up/down).
  • Page spacing adjusts: Sets --wp-admin--admin-bar--height: 0px when hidden, so scroll-padding-top and bump margin-top adjust automatically.
  • Accessible: aria-live region announces state changes; aria-hidden set on the toolbar element.

Changes

  1. src/js/_enqueues/lib/admin-bar.jskeydown listener for Ctrl+Shift+F, toggleToolbar() function, screen reader announcements.
  2. src/wp-includes/css/admin-bar.csshtml.wp-toolbar-hidden rules: CSS variable reset, margin override, transform: translateY(-100%) + visibility: hidden.
  3. src/wp-includes/class-wp-admin-bar.phpwp_localize_script for screen reader strings.

Shortcut rationale

Ctrl+Shift+F was chosen after evaluating and discarding several alternatives:

  • access+w (Ctrl+Option+W / Alt+Shift+W): Initial choice. Discarded because Ctrl+Option on macOS conflicts with the accessibility Display zoom modifier, and Alt+Shift on Windows switches keyboard input language on multi-language setups.
  • Ctrl+Shift+H: "H for Hide" — discarded because Firefox uses Ctrl+Shift+H for the History sidebar.
  • primaryShift+\ (Cmd+Shift+\ / Ctrl+Shift+): Matches Gutenberg's distraction-free mode shortcut. Discarded because \ is not directly accessible on non-US keyboard layouts (e.g. German keyboards require Alt+Shift+7).

Ctrl+Shift+F is free across all major browsers (Chrome, Firefox, Safari, Edge) on all platforms, works on every keyboard layout, and follows the ctrlShift modifier pattern already used in WordPress for region navigation. "F" is mnemonic for "Frontend view."

Prior Art

This PR is based on the keyboard toggle feature from Apermo AdminBar (GitHub) by @apermo. The toggle is also available as a standalone lightweight version: Apermo AdminBar Toggle. The human author of this PR is the plugin author.

Trac ticket: https://core.trac.wordpress.org/ticket/65029

Use of AI Tools

This PR was authored collaboratively with Claude Code (Anthropic Claude Opus 4.6). The AI was used for:

  • Research: Auditing existing WordPress keyboard shortcuts, browser shortcut conflicts, and Trac history for prior proposals.
  • Implementation: Writing the JavaScript toggle logic, CSS hidden state rules, and PHP localization. All code was reviewed and directed by the human author.
  • Trac ticket draft: The ticket description was drafted by AI and reviewed by the human author.

The human author (@apermo) is also the author of the Apermo AdminBar / Apermo AdminBar Toggle plugins that this PR is based on. All code has been reviewed and the human author takes full responsibility for the contents of this PR.


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 access+w (Alt+Shift+W / Ctrl+Option+W) keyboard shortcut to
temporarily hide/show the toolbar on the frontend. Slides the bar
out with a CSS transition and adjusts page spacing via the
--wp-admin--admin-bar--height custom property. Includes screen
reader announcements for accessibility. Frontend only — the
toolbar remains fixed in wp-admin per existing core policy.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

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 apermo.

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

@apermo apermo force-pushed the feature/toolbar-toggle-shortcut branch from e971a61 to 6034341 Compare April 7, 2026 07:14
@apermo apermo closed this Apr 7, 2026
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