From 6b4c1dc8ab0169e64e534c8ad91df06244d27f82 Mon Sep 17 00:00:00 2001 From: Sahejkm <163521239+Sahejkm@users.noreply.github.com> Date: Tue, 21 May 2024 17:47:40 +0800 Subject: [PATCH] [Lexical] add null check for key undefined before calling toLowerCase function (#6154) --- packages/lexical/src/LexicalEvents.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/lexical/src/LexicalEvents.ts b/packages/lexical/src/LexicalEvents.ts index e81ce0a5124..c56806c596e 100644 --- a/packages/lexical/src/LexicalEvents.ts +++ b/packages/lexical/src/LexicalEvents.ts @@ -1005,6 +1005,10 @@ function onKeyDown(event: KeyboardEvent, editor: LexicalEditor): void { return; } + if (key == null) { + return; + } + if (isMoveForward(key, ctrlKey, altKey, metaKey)) { dispatchCommand(editor, KEY_ARROW_RIGHT_COMMAND, event); } else if (isMoveToEnd(key, ctrlKey, shiftKey, altKey, metaKey)) {