From 4fc0ca17b6bc511d68bffd2f9db4c73e0f2d16df Mon Sep 17 00:00:00 2001 From: Eugene Date: Mon, 24 Jul 2023 17:16:51 +0300 Subject: [PATCH] Prevented handling shortcuts with meta/ctrl key --- src/components/editor.ts | 1 + src/components/scroller.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/editor.ts b/src/components/editor.ts index 10a08bc..5167cd5 100644 --- a/src/components/editor.ts +++ b/src/components/editor.ts @@ -38,6 +38,7 @@ export class Editor { this.element.addEventListener('keydown', this.handleKeydown) this.element.value = cell.value this.element.focus() + this.element.select() } handleKeydown = (event: KeyboardEvent) => { diff --git a/src/components/scroller.ts b/src/components/scroller.ts index ad9c700..b445dff 100644 --- a/src/components/scroller.ts +++ b/src/components/scroller.ts @@ -70,6 +70,7 @@ export class Scroller { } private handleKeydown = (event: KeyboardEvent) => { + console.log(event) //* Navigation if (['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(event.key)) { event.preventDefault() @@ -106,11 +107,12 @@ export class Scroller { } } } - - if (event.key === 'F2' || /^([a-z]|[а-я])$/.test(event.key.toLowerCase())) { //* English and Russian keyboard. Or F2 button - event.preventDefault() - if (!this.root.selection.selectedCell) return; - this.root.showEditor(this.root.selection.selectedCell) + if (!event.metaKey && !event.ctrlKey) { //* Prevent handle shortcutrs + if (event.key === 'F2' || /^([a-z]|[а-я])$/.test(event.key.toLowerCase())) { //* English and Russian keyboard. Or F2 button + event.preventDefault() + if (!this.root.selection.selectedCell) return; + this.root.showEditor(this.root.selection.selectedCell) + } } if (event.key === 'Delete') {