Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change shortcut text for redo tooltip on Windows #42830

Merged
merged 2 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/customize-widgets/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand All @@ -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() ] );
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions packages/edit-navigation/src/components/header/redo-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
[]
Expand All @@ -18,7 +22,7 @@ export default function RedoButton() {
<ToolbarButton
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
Expand Down
8 changes: 6 additions & 2 deletions packages/edit-site/src/components/header/undo-redo/redo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import { __, isRTL } from '@wordpress/i18n';
import { Button } 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';
import { forwardRef } from '@wordpress/element';

function RedoButton( props, ref ) {
const shortcut = isAppleOS()
? displayShortcut.primaryShift( 'z' )
: displayShortcut.primary( 'y' );

const hasRedo = useSelect(
( select ) => select( coreStore ).hasRedo(),
[]
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
[]
Expand All @@ -18,7 +22,7 @@ export default function RedoButton() {
<ToolbarButton
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
Expand Down
8 changes: 6 additions & 2 deletions packages/editor/src/components/editor-history/redo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { __, isRTL } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { displayShortcut } from '@wordpress/keycodes';
import { displayShortcut, isAppleOS } from '@wordpress/keycodes';
import { redo as redoIcon, undo as undoIcon } from '@wordpress/icons';
import { forwardRef } from '@wordpress/element';

Expand All @@ -14,6 +14,10 @@ import { forwardRef } from '@wordpress/element';
import { store as editorStore } from '../../store';

function EditorHistoryRedo( props, ref ) {
const shortcut = isAppleOS()
? displayShortcut.primaryShift( 'z' )
: displayShortcut.primary( 'y' );

const hasRedo = useSelect(
( select ) => select( editorStore ).hasEditorRedo(),
[]
Expand All @@ -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
Expand Down