Skip to content

Shortcut: Show keyboard shortcuts left to right on RTL sites - #86606

Merged
mirka merged 3 commits into
WordPress:trunkfrom
shreyasikhar:fix/rtl-keyboard-shortcut-direction
Nov 10, 2026
Merged

mirka merged 3 commits into
WordPress:trunkfrom
shreyasikhar:fix/rtl-keyboard-shortcut-direction

Conversation

@shreyasikhar

@shreyasikhar shreyasikhar commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #86605

Shows keyboard shortcuts left to right on right-to-left sites, so ⌘Z no longer appears as Z⌘ 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 as Ctrl+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/ui already shows shortcuts left to right: KeyboardShortcutDisplay renders with dir="ltr" (#80402). This brings @wordpress/components and the help modals in line with it.

How?

  • Shortcut (@wordpress/components): render the <span> with dir="ltr". This covers the Tooltip and MenuItem shortcuts, which both render through Shortcut.
  • Keyboard shortcuts help modal in @wordpress/editor, @wordpress/edit-widgets and @wordpress/customize-widgets: render each key combination's outer <kbd> with dir="ltr", so the individual keys stay in order.
  • In the three modal stylesheets, mark the last key's margin with /* rtl:ignore */. The key combination is now always LTR, so rtlcss flipping that margin would put the spacing on the wrong side.

The dir attribute is used instead of a direction declaration because it also isolates the shortcut from the surrounding text, and rtlcss doesn't flip HTML attributes.

Testing Instructions

  1. On macOS, go to Settings > General and set the site language to العربية (Arabic).
  2. Create a new post and add a paragraph.
  3. Hover the Undo button in the editor header. The tooltip shows ⌘Z.
  4. Select the paragraph and open the block options menu (⋮). Duplicate shows ⇧⌘D, and Add before shows ⌥⌘T.
  5. Press Control+Option+H. In the Keyboard shortcuts modal, each combination reads in the right order, such as ⌘ K, with even spacing between keys.
  6. With a classic theme active, repeat step 5 on Appearance > Widgets.
  7. Switch the site language back to English and repeat steps 3 to 5. Nothing changes.

Testing Instructions for Keyboard

  1. In the post editor on an RTL site, press Tab until the Undo button has focus. The tooltip shows ⌘Z.
  2. Move focus to a block, press Option+F10 to reach the block toolbar, move to the Options button and press Enter. The menu items show their shortcuts in the right order.
  3. Press Control+Option+H to open the Keyboard shortcuts modal, and check the key combinations.

Screenshots or screencast

Site language Arabic, macOS:

Before After
Block options menu Image Image
Keyboard shortcuts modal Image Image
Undo tooltip Image Image

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

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>
@github-actions github-actions Bot added [Package] Components /packages/components [Package] Editor /packages/editor [Package] Edit Widgets /packages/edit-widgets labels Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: shreyasikhar <shreyasikhar26@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The media editor has its own keyboard shortcuts modal with the same markup and margins, in packages/media-editor/src/components/media-editor-keyboard-shortcuts-modal/. Can we add dir="ltr" to its __shortcut-term <kbd> and update its stylesheet here too?

Media editor shortcuts dialog

Comment on lines 57 to 58
/* rtl:ignore */
margin: 0 0 0 0.2rem;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
/* rtl:ignore */
margin: 0 0 0 0.2rem;
margin-inline-end: 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@shreyasikhar
shreyasikhar requested a review from mirka November 10, 2026 15:29
@mirka mirka added the [Type] Bug An existing feature does not function as intended label Nov 10, 2026
@mirka
mirka enabled auto-merge (squash) November 10, 2026 15:34
@mirka
mirka merged commit 8c3ef73 into WordPress:trunk Nov 10, 2026
93 of 94 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Package] Edit Widgets /packages/edit-widgets [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard shortcuts display in reverse order on right-to-left sites

2 participants