From 48f1999c952bc78dda3ad3eacf5b1ccd7aab6827 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 17 Jul 2025 15:15:18 +0530 Subject: [PATCH] [WIKI-557] fix: keyboard navigation in tables (#7428) --- .../src/core/extensions/table/table/table.ts | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/editor/src/core/extensions/table/table/table.ts b/packages/editor/src/core/extensions/table/table/table.ts index 42ff67177..0bdc4e8d1 100644 --- a/packages/editor/src/core/extensions/table/table/table.ts +++ b/packages/editor/src/core/extensions/table/table/table.ts @@ -219,23 +219,31 @@ export const Table = Node.create({ addKeyboardShortcuts() { return { Tab: () => { - if (this.editor.isActive(CORE_EXTENSIONS.TABLE)) { - if (this.editor.isActive(CORE_EXTENSIONS.LIST_ITEM) || this.editor.isActive(CORE_EXTENSIONS.TASK_ITEM)) { - return false; - } - if (this.editor.commands.goToNextCell()) { - return true; - } + if (!this.editor.isActive(CORE_EXTENSIONS.TABLE)) return false; - if (!this.editor.can().addRowAfter()) { - return false; - } - - return this.editor.chain().addRowAfter().goToNextCell().run(); + if (this.editor.isActive(CORE_EXTENSIONS.LIST_ITEM) || this.editor.isActive(CORE_EXTENSIONS.TASK_ITEM)) { + return false; } - return false; + + if (this.editor.commands.goToNextCell()) { + return true; + } + + if (!this.editor.can().addRowAfter()) { + return false; + } + + return this.editor.chain().addRowAfter().goToNextCell().run(); + }, + "Shift-Tab": () => { + if (!this.editor.isActive(CORE_EXTENSIONS.TABLE)) return false; + + if (this.editor.isActive(CORE_EXTENSIONS.LIST_ITEM) || this.editor.isActive(CORE_EXTENSIONS.TASK_ITEM)) { + return false; + } + + return this.editor.commands.goToPreviousCell(); }, - "Shift-Tab": () => this.editor.commands.goToPreviousCell(), Backspace: handleDeleteKeyOnTable, "Mod-Backspace": handleDeleteKeyOnTable, Delete: handleDeleteKeyOnTable,