Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WIKI-557] fix: keyboard navigation in tables (#7428)

Aaryan Khandelwal48f1999c952b
diff --git a/packages/editor/src/core/extensions/table/table/table.ts b/packages/editor/src/core/extensions/table/table/table.ts
index 42ff67177c..0bdc4e8d1c 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<TableOptions>({
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;
- }
+ if (this.editor.isActive(CORE_EXTENSIONS.LIST_ITEM) || this.editor.isActive(CORE_EXTENSIONS.TASK_ITEM)) {
+ return false;
+ }
- return this.editor.chain().addRowAfter().goToNextCell().run();
+ if (this.editor.commands.goToNextCell()) {
+ return true;
}
- return false;
+
+ 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,