From bba1cfe861f41b8de88246d8b25bc7cce6d5b5df Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Tue, 21 Jul 2026 15:28:11 -0400 Subject: [PATCH] Fix undo shortcuts in text fields --- .../components/global-keyboard-shortcuts/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/editor/src/components/global-keyboard-shortcuts/index.js b/packages/editor/src/components/global-keyboard-shortcuts/index.js index 26bf21e5917ca1..9fe0e2a057dd4f 100644 --- a/packages/editor/src/components/global-keyboard-shortcuts/index.js +++ b/packages/editor/src/components/global-keyboard-shortcuts/index.js @@ -11,6 +11,10 @@ import { store as blockEditorStore } from '@wordpress/block-editor'; */ import { store as editorStore } from '../../store'; +function isKeyboardEventFromInputOrTextarea( event ) { + return [ 'INPUT', 'TEXTAREA' ].includes( event.target?.nodeName ); +} + /** * Handles the keyboard shortcuts for the editor. * @@ -61,11 +65,19 @@ export default function EditorKeyboardShortcuts() { } ); useShortcut( 'core/editor/undo', ( event ) => { + if ( isKeyboardEventFromInputOrTextarea( event ) ) { + return; + } + undo(); event.preventDefault(); } ); useShortcut( 'core/editor/redo', ( event ) => { + if ( isKeyboardEventFromInputOrTextarea( event ) ) { + return; + } + redo(); event.preventDefault(); } );