From 4576fbee1e1db55fb541f9d8ef0c3ed38b6c6037 Mon Sep 17 00:00:00 2001 From: wenincode Date: Fri, 13 Oct 2023 16:17:44 -0600 Subject: [PATCH] Guard against null in aria-menu --- ui/packages/consul-ui/app/modifiers/aria-menu.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/packages/consul-ui/app/modifiers/aria-menu.js b/ui/packages/consul-ui/app/modifiers/aria-menu.js index 86188845cdda..5fc5ec165f77 100644 --- a/ui/packages/consul-ui/app/modifiers/aria-menu.js +++ b/ui/packages/consul-ui/app/modifiers/aria-menu.js @@ -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)]; @@ -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) { @@ -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(); }