From 15df9e5e5cbae5afda1daeb9f693677b5ae36b4c Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Mon, 7 Apr 2025 13:01:22 +0200 Subject: [PATCH] Fix issue when pressing `Ctrl/Cmd+A` in a text input inside a modal dialog --- docs/changelog.md | 1 + src/components/App.vue | 7 +++++-- src/components/BufferSelector.vue | 6 ++++++ src/components/EditBuffer.vue | 6 ++++++ src/components/LanguageSelector.vue | 6 ++++++ src/components/NewBuffer.vue | 6 ++++++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index c8c65f3..709fea0 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -5,6 +5,7 @@ Here are the most notable changes in each release. For a more detailed list of c ## 2.1.4 (not released yet) - Fix issue with positioning and size of todo list checkboxes in Markdown blocks when using a non-default font size, or a non-monospaced font. +- Fix issue when pressing `Ctrl/Cmd+A` in a text input inside a modal dialog (e.g. the buffer selector). Previously the select all command would be sent to the editor. ## 2.1.3 diff --git a/src/components/App.vue b/src/components/App.vue index fa20814..5a762e9 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -85,11 +85,14 @@ "showCreateBuffer", "showEditBuffer", "showMoveToBufferSelector", - "openMoveToBufferSelector", ]), + dialogVisible() { + return this.showLanguageSelector || this.showBufferSelector || this.showCreateBuffer || this.showEditBuffer || this.showMoveToBufferSelector + }, + editorInert() { - return this.showCreateBuffer || this.showSettings || this.showEditBuffer + return this.dialogVisible }, }, diff --git a/src/components/BufferSelector.vue b/src/components/BufferSelector.vue index 2a4693b..3ba88be 100644 --- a/src/components/BufferSelector.vue +++ b/src/components/BufferSelector.vue @@ -133,6 +133,12 @@ return } + // support Ctrl/Cmd+A to select all + if (event.key === "a" && event[window.heynote.platform.isMac ? "metaKey" : "ctrlKey"]) { + event.preventDefault() + event.srcElement.select() + } + if (this.filteredItems.length === 0) { return } diff --git a/src/components/EditBuffer.vue b/src/components/EditBuffer.vue index 2ef8c1c..7171aed 100644 --- a/src/components/EditBuffer.vue +++ b/src/components/EditBuffer.vue @@ -120,6 +120,12 @@ }, onInputKeydown(event) { + // support Ctrl/Cmd+A to select all + if (event.key === "a" && event[window.heynote.platform.isMac ? "metaKey" : "ctrlKey"]) { + event.preventDefault() + event.srcElement.select() + } + // redirect arrow keys and page up/down to folder selector const redirectKeys = ["ArrowDown", "ArrowUp", "PageDown", "PageUp"] if (redirectKeys.includes(event.key)) { diff --git a/src/components/LanguageSelector.vue b/src/components/LanguageSelector.vue index cc08107..d9cc8f6 100644 --- a/src/components/LanguageSelector.vue +++ b/src/components/LanguageSelector.vue @@ -50,6 +50,12 @@ methods: { onKeydown(event) { + // support Ctrl/Cmd+A to select all + if (event.key === "a" && event[window.heynote.platform.isMac ? "metaKey" : "ctrlKey"]) { + event.preventDefault() + event.srcElement.select() + } + if (event.key === "ArrowDown") { this.selected = Math.min(this.selected + 1, this.filteredItems.length - 1) event.preventDefault() diff --git a/src/components/NewBuffer.vue b/src/components/NewBuffer.vue index 27bb986..6eecfcc 100644 --- a/src/components/NewBuffer.vue +++ b/src/components/NewBuffer.vue @@ -128,6 +128,12 @@ }, onInputKeydown(event) { + // support Ctrl/Cmd+A to select all + if (event.key === "a" && event[window.heynote.platform.isMac ? "metaKey" : "ctrlKey"]) { + event.preventDefault() + event.srcElement.select() + } + // redirect arrow keys and page up/down to folder selector const redirectKeys = ["ArrowDown", "ArrowUp", "PageDown", "PageUp"] if (redirectKeys.includes(event.key)) {