Skip to content

Commit

Permalink
Guard against null in aria-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
wenincode authored and chris-hut committed Oct 16, 2023
1 parent bbedb3f commit 4576fbe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ui/packages/consul-ui/app/modifiers/aria-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class AriaMenuModifier extends Modifier {
async keydown(e) {
if (e.keyCode === ESC) {
this.options.onclose(e);
this.$trigger.focus();
this.$trigger?.focus();
return;
}
const $items = [...this.element.querySelectorAll(MENU_ITEMS)];
Expand All @@ -62,7 +62,7 @@ export default class AriaMenuModifier extends Modifier {
if (e.shiftKey) {
if (pos === 0) {
this.options.onclose(e);
this.$trigger.focus();
this.$trigger?.focus();
}
} else {
if (pos === $items.length - 1) {
Expand All @@ -75,7 +75,7 @@ export default class AriaMenuModifier extends Modifier {
if (typeof keys[this.orientation][e.keyCode] === 'undefined') {
return;
}
$items[keys[this.orientation][e.keyCode]($items, pos)].focus();
$items[keys[this.orientation][e.keyCode]($items, pos)]?.focus();
e.stopPropagation();
e.preventDefault();
}
Expand Down

0 comments on commit 4576fbe

Please sign in to comment.