Closes the menu.
(opts: {refocus?: boolean} = {})
| 737 | |
| 738 | /** Closes the menu. */ |
| 739 | close(opts: {refocus?: boolean} = {}) { |
| 740 | this.expanded.set(false); |
| 741 | this.pendingFocus.set(undefined); |
| 742 | this.menu()?.listBehavior.unfocus(); |
| 743 | |
| 744 | if (opts.refocus) { |
| 745 | this.inputs.element()?.focus(); |
| 746 | } |
| 747 | |
| 748 | let menuitems = this.inputs.menu()?.inputs.items() ?? []; |
| 749 | |
| 750 | while (menuitems.length) { |
| 751 | const menuitem = menuitems.pop(); |
| 752 | menuitem?._expanded.set(false); |
| 753 | menuitem?.inputs.parent()?.listBehavior.unfocus(); |
| 754 | menuitems = menuitems.concat(menuitem?.submenu()?.inputs.items() ?? []); |
| 755 | } |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | /** The menu item ui pattern class. */ |