diff --git a/src/ui/menu-ui-handler.ts b/src/ui/menu-ui-handler.ts index 65637689d49..755267fcede 100644 --- a/src/ui/menu-ui-handler.ts +++ b/src/ui/menu-ui-handler.ts @@ -331,11 +331,15 @@ export default class MenuUiHandler extends MessageUiHandler { if (button === Button.ACTION) { let adjustedCursor = this.cursor; - for (const imo of this.excludedMenus().find(e => e.condition).options.sort()) { - if (adjustedCursor >= imo) { - adjustedCursor++; - } else { - break; + const excludedMenu = this.excludedMenus().find(e => e.condition); + if (excludedMenu !== null && excludedMenu.options.length > 0) { + const sortedOptions = excludedMenu.options.sort(); + for (const imo of sortedOptions) { + if (adjustedCursor >= imo) { + adjustedCursor++; + } else { + break; + } } } switch (adjustedCursor) {