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