From e3a87ea5e328ccf563e24eb959a073c400eff688 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Mon, 29 Aug 2022 10:27:23 +0100 Subject: [PATCH] Fixed #2886 - Dropdown: Prevent show of overlay when pressing meta key --- src/components/cascadeselect/CascadeSelect.vue | 4 +++- src/components/dropdown/Dropdown.vue | 4 +++- src/components/listbox/Listbox.vue | 6 ++++-- src/components/multiselect/MultiSelect.vue | 6 ++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/cascadeselect/CascadeSelect.vue b/src/components/cascadeselect/CascadeSelect.vue index 3f0d021bd..b0d158b2a 100644 --- a/src/components/cascadeselect/CascadeSelect.vue +++ b/src/components/cascadeselect/CascadeSelect.vue @@ -225,6 +225,8 @@ export default { return; } + const metaKey = event.metaKey || event.ctrlKey; + switch (event.code) { case 'ArrowDown': this.onArrowDownKey(event); @@ -275,7 +277,7 @@ export default { break; default: - if (ObjectUtils.isPrintableCharacter(event.key)) { + if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) { !this.overlayVisible && this.show(); this.searchOptions(event, event.key); } diff --git a/src/components/dropdown/Dropdown.vue b/src/components/dropdown/Dropdown.vue index 55e37ae96..bdf360a3e 100755 --- a/src/components/dropdown/Dropdown.vue +++ b/src/components/dropdown/Dropdown.vue @@ -287,6 +287,8 @@ export default { this.$emit('blur', event); }, onKeyDown(event) { + const metaKey = event.metaKey || event.ctrlKey; + switch (event.code) { case 'ArrowDown': this.onArrowDownKey(event); @@ -343,7 +345,7 @@ export default { break; default: - if (ObjectUtils.isPrintableCharacter(event.key)) { + if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) { !this.overlayVisible && this.show(); !this.editable && this.searchOptions(event, event.key); } diff --git a/src/components/listbox/Listbox.vue b/src/components/listbox/Listbox.vue index 0cdece29c..d8eea3423 100755 --- a/src/components/listbox/Listbox.vue +++ b/src/components/listbox/Listbox.vue @@ -221,6 +221,8 @@ export default { this.$emit('blur', event); }, onListKeyDown(event) { + const metaKey = event.metaKey || event.ctrlKey; + switch (event.code) { case 'ArrowDown': this.onArrowDownKey(event); @@ -261,7 +263,7 @@ export default { break; default: - if (event.code === 'KeyA' && this.multiple && (event.metaKey || event.ctrlKey)) { + if (this.multiple && event.code === 'KeyA' && metaKey) { const value = this.visibleOptions.filter(option => this.isValidOption(option)).map(option => this.getOptionValue(option)); this.updateModel(event, value); @@ -269,7 +271,7 @@ export default { break; } - if (ObjectUtils.isPrintableCharacter(event.key)) { + if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) { this.searchOptions(event, event.key); event.preventDefault(); } diff --git a/src/components/multiselect/MultiSelect.vue b/src/components/multiselect/MultiSelect.vue index e427a4def..97e6feeef 100755 --- a/src/components/multiselect/MultiSelect.vue +++ b/src/components/multiselect/MultiSelect.vue @@ -336,6 +336,8 @@ export default { this.$emit('blur', event); }, onKeyDown(event) { + const metaKey = event.metaKey || event.ctrlKey; + switch (event.code) { case 'ArrowDown': this.onArrowDownKey(event); @@ -380,7 +382,7 @@ export default { break; default: - if (event.code === 'KeyA' && (event.metaKey || event.ctrlKey)) { + if (event.code === 'KeyA' && metaKey) { const value = this.visibleOptions.filter(option => this.isValidOption(option)).map(option => this.getOptionValue(option)); this.updateModel(event, value); @@ -388,7 +390,7 @@ export default { break; } - if (ObjectUtils.isPrintableCharacter(event.key)) { + if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) { !this.overlayVisible && this.show(); this.searchOptions(event); event.preventDefault();