Fixed #2886 - Dropdown: Prevent show of overlay when pressing meta key

pull/2910/head
mertsincan 2022-08-29 10:27:23 +01:00
parent a7a70aba97
commit e3a87ea5e3
4 changed files with 14 additions and 6 deletions

View File

@ -225,6 +225,8 @@ export default {
return; return;
} }
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) { switch (event.code) {
case 'ArrowDown': case 'ArrowDown':
this.onArrowDownKey(event); this.onArrowDownKey(event);
@ -275,7 +277,7 @@ export default {
break; break;
default: default:
if (ObjectUtils.isPrintableCharacter(event.key)) { if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
!this.overlayVisible && this.show(); !this.overlayVisible && this.show();
this.searchOptions(event, event.key); this.searchOptions(event, event.key);
} }

View File

@ -287,6 +287,8 @@ export default {
this.$emit('blur', event); this.$emit('blur', event);
}, },
onKeyDown(event) { onKeyDown(event) {
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) { switch (event.code) {
case 'ArrowDown': case 'ArrowDown':
this.onArrowDownKey(event); this.onArrowDownKey(event);
@ -343,7 +345,7 @@ export default {
break; break;
default: default:
if (ObjectUtils.isPrintableCharacter(event.key)) { if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
!this.overlayVisible && this.show(); !this.overlayVisible && this.show();
!this.editable && this.searchOptions(event, event.key); !this.editable && this.searchOptions(event, event.key);
} }

View File

@ -221,6 +221,8 @@ export default {
this.$emit('blur', event); this.$emit('blur', event);
}, },
onListKeyDown(event) { onListKeyDown(event) {
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) { switch (event.code) {
case 'ArrowDown': case 'ArrowDown':
this.onArrowDownKey(event); this.onArrowDownKey(event);
@ -261,7 +263,7 @@ export default {
break; break;
default: 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)); const value = this.visibleOptions.filter(option => this.isValidOption(option)).map(option => this.getOptionValue(option));
this.updateModel(event, value); this.updateModel(event, value);
@ -269,7 +271,7 @@ export default {
break; break;
} }
if (ObjectUtils.isPrintableCharacter(event.key)) { if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
this.searchOptions(event, event.key); this.searchOptions(event, event.key);
event.preventDefault(); event.preventDefault();
} }

View File

@ -336,6 +336,8 @@ export default {
this.$emit('blur', event); this.$emit('blur', event);
}, },
onKeyDown(event) { onKeyDown(event) {
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) { switch (event.code) {
case 'ArrowDown': case 'ArrowDown':
this.onArrowDownKey(event); this.onArrowDownKey(event);
@ -380,7 +382,7 @@ export default {
break; break;
default: 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)); const value = this.visibleOptions.filter(option => this.isValidOption(option)).map(option => this.getOptionValue(option));
this.updateModel(event, value); this.updateModel(event, value);
@ -388,7 +390,7 @@ export default {
break; break;
} }
if (ObjectUtils.isPrintableCharacter(event.key)) { if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
!this.overlayVisible && this.show(); !this.overlayVisible && this.show();
this.searchOptions(event); this.searchOptions(event);
event.preventDefault(); event.preventDefault();