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