Toolbar: Add access+w keyboard shortcut to toggle toolbar on frontend#39
Closed
Toolbar: Add access+w keyboard shortcut to toggle toolbar on frontend#39
Conversation
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.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
e971a61 to
6034341
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
--wp-admin--admin-bar--height: 0pxwhen hidden, soscroll-padding-topand bumpmargin-topadjust automatically.aria-liveregion announces state changes;aria-hiddenset on the toolbar element.Changes
src/js/_enqueues/lib/admin-bar.js—keydownlistener forCtrl+Shift+F,toggleToolbar()function, screen reader announcements.src/wp-includes/css/admin-bar.css—html.wp-toolbar-hiddenrules: CSS variable reset, margin override,transform: translateY(-100%)+visibility: hidden.src/wp-includes/class-wp-admin-bar.php—wp_localize_scriptfor screen reader strings.Shortcut rationale
Ctrl+Shift+Fwas chosen after evaluating and discarding several alternatives:access+w(Ctrl+Option+W / Alt+Shift+W): Initial choice. Discarded becauseCtrl+Optionon macOS conflicts with the accessibility Display zoom modifier, andAlt+Shifton Windows switches keyboard input language on multi-language setups.Ctrl+Shift+H: "H for Hide" — discarded because Firefox usesCtrl+Shift+Hfor 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 requireAlt+Shift+7).Ctrl+Shift+Fis free across all major browsers (Chrome, Firefox, Safari, Edge) on all platforms, works on every keyboard layout, and follows thectrlShiftmodifier 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:
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.