From c197dcf0cc6f9102e364a022e0e346287e2ae996 Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Wed, 30 Nov 2022 10:14:34 +0200 Subject: [PATCH] Block editor: rich text: return early if __experimentalUndo is not defined (#46152) --- .../src/components/rich-text/use-undo-automatic-change.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/rich-text/use-undo-automatic-change.js b/packages/block-editor/src/components/rich-text/use-undo-automatic-change.js index 890746cec74a35..819f2935806263 100644 --- a/packages/block-editor/src/components/rich-text/use-undo-automatic-change.js +++ b/packages/block-editor/src/components/rich-text/use-undo-automatic-change.js @@ -28,12 +28,18 @@ export function useUndoAutomaticChange() { return; } + const { __experimentalUndo } = getSettings(); + + if ( ! __experimentalUndo ) { + return; + } + if ( ! didAutomaticChange() ) { return; } event.preventDefault(); - getSettings().__experimentalUndo(); + __experimentalUndo(); } element.addEventListener( 'keydown', onKeyDown );