Skip to content

Commit

Permalink
Fixed #2886 - Dropdown: Prevent show of overlay when pressing meta key
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Aug 29, 2022
1 parent a7a70ab commit e3a87ea
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/components/cascadeselect/CascadeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ export default {
return;
}
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) {
case 'ArrowDown':
this.onArrowDownKey(event);
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions src/components/listbox/Listbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -261,15 +263,15 @@ 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);
event.preventDefault();
break;
}
if (ObjectUtils.isPrintableCharacter(event.key)) {
if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
this.searchOptions(event, event.key);
event.preventDefault();
}
Expand Down
6 changes: 4 additions & 2 deletions src/components/multiselect/MultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -380,15 +382,15 @@ 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);
event.preventDefault();
break;
}
if (ObjectUtils.isPrintableCharacter(event.key)) {
if (!metaKey && ObjectUtils.isPrintableCharacter(event.key)) {
!this.overlayVisible && this.show();
this.searchOptions(event);
event.preventDefault();
Expand Down

0 comments on commit e3a87ea

Please sign in to comment.