Goes to and optionally focuses the specified menu item.
(item: MenuItemPattern<V>, opts?: {focusElement?: boolean})
| 593 | |
| 594 | /** Goes to and optionally focuses the specified menu item. */ |
| 595 | goto(item: MenuItemPattern<V>, opts?: {focusElement?: boolean}) { |
| 596 | const prevItem = this.inputs.activeItem(); |
| 597 | this.listBehavior.goto(item, opts); |
| 598 | |
| 599 | if (prevItem?.expanded()) { |
| 600 | prevItem?.close(); |
| 601 | this.inputs.activeItem()?.open(); |
| 602 | } |
| 603 | |
| 604 | if (item === prevItem) { |
| 605 | if (item.expanded() && item.submenu()?.inputs.activeItem()) { |
| 606 | item.submenu()?.inputs.activeItem()?.close(); |
| 607 | item.submenu()?.listBehavior.unfocus(); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | /** Focuses the next menu item. */ |
| 613 | next() { |
no test coverage detected