From fa2fcf4f08bc58a695d59b48f1342ccd2acada33 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 6 Mar 2024 20:29:41 +0100 Subject: [PATCH] only apply keybind when visible --- .../components/inputs/GlobalSearchDialog.vue | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/vue3/src/components/inputs/GlobalSearchDialog.vue b/vue3/src/components/inputs/GlobalSearchDialog.vue index 93d9550e3..cb190fd6d 100644 --- a/vue3/src/components/inputs/GlobalSearchDialog.vue +++ b/vue3/src/components/inputs/GlobalSearchDialog.vue @@ -128,18 +128,20 @@ export default defineComponent({ mounted() { // add keyhandlers window.addEventListener('keydown', (e) => { - if (e.key == 'ArrowUp') { - this.selected_result = Math.max(0, this.selected_result - 1) - } - if (e.key == 'ArrowDown') { - this.selected_result = Math.min(this.search_results.length, this.selected_result + 1) - } - if (e.key == 'Enter') { - this.goToSelectedRecipe() - } - if (e.key == 'k' && e.ctrlKey) { - this.dialog = true - e.preventDefault() + if (this.dialog) { + if (e.key == 'ArrowUp') { + this.selected_result = Math.max(0, this.selected_result - 1) + } + if (e.key == 'ArrowDown') { + this.selected_result = Math.min(this.search_results.length, this.selected_result + 1) + } + if (e.key == 'Enter') { + this.goToSelectedRecipe() + } + if (e.key == 'k' && e.ctrlKey) { + this.dialog = true + e.preventDefault() + } } })