diff --git a/packages/customize-widgets/src/components/header/index.js b/packages/customize-widgets/src/components/header/index.js index b23c75de1d7ed6..201831b90cd78a 100644 --- a/packages/customize-widgets/src/components/header/index.js +++ b/packages/customize-widgets/src/components/header/index.js @@ -10,7 +10,7 @@ import { createPortal, useState, useEffect } from '@wordpress/element'; import { __, _x, isRTL } from '@wordpress/i18n'; import { ToolbarButton } from '@wordpress/components'; import { NavigableToolbar } from '@wordpress/block-editor'; -import { displayShortcut } from '@wordpress/keycodes'; +import { displayShortcut, isAppleOS } from '@wordpress/keycodes'; import { plus, undo as undoIcon, redo as redoIcon } from '@wordpress/icons'; /** @@ -31,6 +31,10 @@ function Header( { sidebar.hasRedo(), ] ); + const shortcut = isAppleOS() + ? displayShortcut.primaryShift( 'z' ) + : displayShortcut.primary( 'y' ); + useEffect( () => { return sidebar.subscribeHistory( () => { setUndoRedo( [ sidebar.hasUndo(), sidebar.hasRedo() ] ); @@ -64,7 +68,7 @@ function Header( { icon={ ! isRTL() ? redoIcon : undoIcon } /* translators: button label text should, if possible, be under 16 characters. */ label={ __( 'Redo' ) } - shortcut={ displayShortcut.primaryShift( 'z' ) } + shortcut={ shortcut } // If there are no undo levels we don't want to actually disable this // button, because it will remove focus for keyboard users. // See: https://github.com/WordPress/gutenberg/issues/3486 diff --git a/packages/edit-navigation/src/components/header/redo-button.js b/packages/edit-navigation/src/components/header/redo-button.js index 70521b1d0eceaf..c4f4e6df37b915 100644 --- a/packages/edit-navigation/src/components/header/redo-button.js +++ b/packages/edit-navigation/src/components/header/redo-button.js @@ -5,10 +5,14 @@ import { __, isRTL } from '@wordpress/i18n'; import { ToolbarButton } from '@wordpress/components'; import { useSelect, useDispatch } from '@wordpress/data'; import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons'; -import { displayShortcut } from '@wordpress/keycodes'; +import { displayShortcut, isAppleOS } from '@wordpress/keycodes'; import { store as coreStore } from '@wordpress/core-data'; export default function RedoButton() { + const shortcut = isAppleOS() + ? displayShortcut.primaryShift( 'z' ) + : displayShortcut.primary( 'y' ); + const hasRedo = useSelect( ( select ) => select( coreStore ).hasRedo(), [] @@ -18,7 +22,7 @@ export default function RedoButton() { select( coreStore ).hasRedo(), [] @@ -21,7 +25,7 @@ function RedoButton( props, ref ) { ref={ ref } icon={ ! isRTL() ? redoIcon : undoIcon } label={ __( 'Redo' ) } - shortcut={ displayShortcut.primaryShift( 'z' ) } + shortcut={ shortcut } // If there are no undo levels we don't want to actually disable this // button, because it will remove focus for keyboard users. // See: https://github.com/WordPress/gutenberg/issues/3486 diff --git a/packages/edit-widgets/src/components/header/undo-redo/redo.js b/packages/edit-widgets/src/components/header/undo-redo/redo.js index 70521b1d0eceaf..c4f4e6df37b915 100644 --- a/packages/edit-widgets/src/components/header/undo-redo/redo.js +++ b/packages/edit-widgets/src/components/header/undo-redo/redo.js @@ -5,10 +5,14 @@ import { __, isRTL } from '@wordpress/i18n'; import { ToolbarButton } from '@wordpress/components'; import { useSelect, useDispatch } from '@wordpress/data'; import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons'; -import { displayShortcut } from '@wordpress/keycodes'; +import { displayShortcut, isAppleOS } from '@wordpress/keycodes'; import { store as coreStore } from '@wordpress/core-data'; export default function RedoButton() { + const shortcut = isAppleOS() + ? displayShortcut.primaryShift( 'z' ) + : displayShortcut.primary( 'y' ); + const hasRedo = useSelect( ( select ) => select( coreStore ).hasRedo(), [] @@ -18,7 +22,7 @@ export default function RedoButton() { select( editorStore ).hasEditorRedo(), [] @@ -26,7 +30,7 @@ function EditorHistoryRedo( props, ref ) { icon={ ! isRTL() ? redoIcon : undoIcon } /* translators: button label text should, if possible, be under 16 characters. */ label={ __( 'Redo' ) } - shortcut={ displayShortcut.primaryShift( 'z' ) } + shortcut={ shortcut } // If there are no redo levels we don't want to actually disable this // button, because it will remove focus for keyboard users. // See: https://github.com/WordPress/gutenberg/issues/3486