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