Closes the submenu.
(opts: {refocus?: boolean} = {})
| 837 | |
| 838 | /** Closes the submenu. */ |
| 839 | close(opts: {refocus?: boolean} = {}) { |
| 840 | this._expanded.set(false); |
| 841 | |
| 842 | if (opts.refocus) { |
| 843 | this.inputs.parent()?.listBehavior.goto(this); |
| 844 | } |
| 845 | |
| 846 | let menuitems = this.inputs.submenu()?.inputs.items() ?? []; |
| 847 | |
| 848 | while (menuitems.length) { |
| 849 | const menuitem = menuitems.pop(); |
| 850 | menuitem?._expanded.set(false); |
| 851 | menuitem?.inputs.parent()?.listBehavior.unfocus(); |
| 852 | menuitems = menuitems.concat(menuitem?.submenu()?.inputs.items() ?? []); |
| 853 | |
| 854 | const parent = menuitem?.inputs.parent(); |
| 855 | |
| 856 | if (parent instanceof MenuPattern) { |
| 857 | parent._clearTimeouts(); |
| 858 | } |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | /** Handles focusin events for the menu item. */ |
| 863 | onFocusIn() { |
nothing calls this directly
no test coverage detected