From 6872eb802c3c7bf9fed1e21eb7dc691a5e09af98 Mon Sep 17 00:00:00 2001
From: Dan Brown <ssddanbrown@googlemail.com>
Date: Fri, 13 Sep 2024 16:05:55 +0100
Subject: [PATCH] Lexical: Altered keyboard handling to indicant handled state

---
 .../js/wysiwyg/services/keyboard-handling.ts   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/resources/js/wysiwyg/services/keyboard-handling.ts b/resources/js/wysiwyg/services/keyboard-handling.ts
index 791fb0bed..2c7bfdbba 100644
--- a/resources/js/wysiwyg/services/keyboard-handling.ts
+++ b/resources/js/wysiwyg/services/keyboard-handling.ts
@@ -58,15 +58,19 @@ function insertAfterSingleSelectedNode(editor: LexicalEditor, event: KeyboardEve
     return false;
 }
 
-function handleInsetOnTab(editor: LexicalEditor, event: KeyboardEvent|null) {
+function handleInsetOnTab(editor: LexicalEditor, event: KeyboardEvent|null): boolean {
     const change = event?.shiftKey ? -40 : 40;
-    editor.update(() => {
-        const selection = $getSelection();
-        const nodes = selection?.getNodes() || [];
-        if (nodes.length > 1 || (nodes.length === 1 && $isCustomListItemNode(nodes[0].getParent()))) {
+    const selection = $getSelection();
+    const nodes = selection?.getNodes() || [];
+    if (nodes.length > 1 || (nodes.length === 1 && $isCustomListItemNode(nodes[0].getParent()))) {
+        editor.update(() => {
             $setInsetForSelection(editor, change);
-        }
-    });
+        });
+        event?.preventDefault();
+        return true;
+    }
+
+    return false;
 }
 
 export function registerKeyboardHandling(context: EditorUiContext): () => void {