Closes the menu.
(opts: {refocus?: boolean} = {})
| 767 | |
| 768 | /** Closes the menu. */ |
| 769 | close(opts: {refocus?: boolean} = {}) { |
| 770 | this.expanded.set(false); |
| 771 | this.pendingFocus.set(undefined); |
| 772 | this.menu()?.listBehavior.unfocus(); |
| 773 | |
| 774 | if (opts.refocus) { |
| 775 | this.inputs.element()?.focus(); |
| 776 | } |
| 777 | |
| 778 | let menuitems = this.inputs.menu()?.inputs.items() ?? []; |
| 779 | |
| 780 | while (menuitems.length) { |
| 781 | const menuitem = menuitems.pop(); |
| 782 | menuitem?._expanded.set(false); |
| 783 | menuitem?.inputs.parent()?.listBehavior.unfocus(); |
| 784 | menuitems = menuitems.concat(menuitem?.submenu()?.inputs.items() ?? []); |
| 785 | } |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | /** The menu item ui pattern class. */ |