Skip to content

Commit

Permalink
Fixed #3512 - DropdownMenu: Disabled dropdown can still be opened wit…
Browse files Browse the repository at this point in the history
…h screen reader
  • Loading branch information
mertsincan committed Jan 11, 2023
1 parent c3c3edc commit df3f1ca
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
22 changes: 22 additions & 0 deletions components/autocomplete/AutoComplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ export default {
}, 0); // For ScreenReaders
},
onFocus(event) {
if (this.disabled) {
// For ScreenReaders
return;
}
if (!this.dirty && this.completeOnFocus) {
this.search(event, event.target.value, 'focus');
}
Expand All @@ -424,6 +429,12 @@ export default {
this.$emit('blur', event);
},
onKeyDown(event) {
if (this.disabled) {
event.preventDefault();
return;
}
switch (event.code) {
case 'ArrowDown':
this.onArrowDownKey(event);
Expand Down Expand Up @@ -529,13 +540,24 @@ export default {
}
},
onMultipleContainerFocus() {
if (this.disabled) {
// For ScreenReaders
return;
}
this.focused = true;
},
onMultipleContainerBlur() {
this.focusedMultipleOptionIndex = -1;
this.focused = false;
},
onMultipleContainerKeyDown(event) {
if (this.disabled) {
event.preventDefault();
return;
}
switch (event.code) {
case 'ArrowLeft':
this.onArrowLeftKeyOnMultiple(event);
Expand Down
5 changes: 5 additions & 0 deletions components/cascadeselect/CascadeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ export default {
}, 0); // For ScreenReaders
},
onFocus(event) {
if (this.disabled) {
// For ScreenReaders
return;
}
this.focused = true;
this.$emit('focus', event);
},
Expand Down
11 changes: 11 additions & 0 deletions components/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ export default {
}, 0); // For ScreenReaders
},
onFocus(event) {
if (this.disabled) {
// For ScreenReaders
return;
}
this.focused = true;
this.focusedOptionIndex = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : this.overlayVisible && this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1;
this.overlayVisible && this.scrollInView(this.focusedOptionIndex);
Expand All @@ -409,6 +414,12 @@ export default {
this.$emit('blur', event);
},
onKeyDown(event) {
if (this.disabled) {
event.preventDefault();
return;
}
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) {
Expand Down
11 changes: 11 additions & 0 deletions components/multiselect/MultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ export default {
}, 0); // For ScreenReaders
},
onFocus(event) {
if (this.disabled) {
// For ScreenReaders
return;
}
this.focused = true;
this.focusedOptionIndex = this.focusedOptionIndex !== -1 ? this.focusedOptionIndex : this.overlayVisible && this.autoOptionFocus ? this.findFirstFocusedOptionIndex() : -1;
this.overlayVisible && this.scrollInView(this.focusedOptionIndex);
Expand All @@ -424,6 +429,12 @@ export default {
this.$emit('blur', event);
},
onKeyDown(event) {
if (this.disabled) {
event.preventDefault();
return;
}
const metaKey = event.metaKey || event.ctrlKey;
switch (event.code) {
Expand Down

0 comments on commit df3f1ca

Please sign in to comment.