Repository navigation
Shortcut: Show keyboard shortcuts left to right on RTL sites - #86606
Conversation
On right-to-left sites, macOS shortcut labels displayed with their keys reversed (for example `Z⌘` instead of `⌘Z`), because the modifier symbols have no bidi direction and inherit the page's RTL direction. Render the `Shortcut` component and the keyboard shortcuts help modal key combinations with `dir="ltr"`, matching `KeyboardShortcutDisplay` in `@wordpress/ui`. Keep the modal's last-key margin out of the RTL stylesheet so key spacing stays correct inside the LTR combination. Fixes WordPress#86605. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| /* rtl:ignore */ | ||
| margin: 0 0 0 0.2rem; |
There was a problem hiding this comment.
Since the combination is always LTR now, margin-inline-end: 0 gives the same result without the rtlcss directive, because rtlcss doesn't flip logical properties. Same in the edit-widgets and customize-widgets stylesheets.
| /* rtl:ignore */ | |
| margin: 0 0 0 0.2rem; | |
| margin-inline-end: 0; |
There was a problem hiding this comment.
Thanks! Switched the last-key margin to margin-inline-end: 0 in all three modals, and applied the same fix to the media editor's shortcuts modal, with a changelog entry. Checked it in Arabic: the keys now read in order with even spacing.
…tor modal Replace the `rtl:ignore` margin on the last key with `margin-inline-end: 0`. The key combination is always LTR now, and rtlcss doesn't flip logical properties, so no directive is needed. Apply the same fix to the media editor's keyboard shortcuts modal: render its key combination with `dir="ltr"` and use the same margin.

What?
Closes #86605
Shows keyboard shortcuts left to right on right-to-left sites, so
⌘Zno longer appears asZ⌘in tooltips, menu items and the keyboard shortcuts help modal.Why?
On a site in an RTL language, such as Arabic or Hebrew, macOS shortcut labels display with their keys in reverse order. The modifier symbols (
⌘,⇧,⌥,⌃) have no bidi direction of their own, so they inherit the page's RTL direction and the browser reorders them around the letter. The Windows and Linux labels, such asCtrl+Shift+Z, are all Latin letters and already show left to right, so the same shortcut showed in a different order depending on the operating system.@wordpress/uialready shows shortcuts left to right:KeyboardShortcutDisplayrenders withdir="ltr"(#80402). This brings@wordpress/componentsand the help modals in line with it.How?
Shortcut(@wordpress/components): render the<span>withdir="ltr". This covers theTooltipandMenuItemshortcuts, which both render throughShortcut.@wordpress/editor,@wordpress/edit-widgetsand@wordpress/customize-widgets: render each key combination's outer<kbd>withdir="ltr", so the individual keys stay in order./* rtl:ignore */. The key combination is now always LTR, so rtlcss flipping that margin would put the spacing on the wrong side.The
dirattribute is used instead of adirectiondeclaration because it also isolates the shortcut from the surrounding text, and rtlcss doesn't flip HTML attributes.Testing Instructions
⌘Z.⇧⌘D, and Add before shows⌥⌘T.⌘K, with even spacing between keys.Testing Instructions for Keyboard
⌘Z.Screenshots or screencast
Site language Arabic, macOS:
The LTR display is unchanged.
Use of AI Tools
Claude Code helped find the bug, write the fix, update the tests and changelogs, and check the result in a browser in both RTL and LTR. I reviewed the changes and the screenshots.
🤖 Generated with Claude Code