MCPcopy Create free account
hub / github.com/angular/components / close

Method close

src/aria/private/menu/menu.ts:840–861  ·  view source on GitHub ↗

Closes the submenu.

(opts: {refocus?: boolean} = {})

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

setMethod · 0.80
parentMethod · 0.80
_clearTimeoutsMethod · 0.80
unfocusMethod · 0.65
gotoMethod · 0.45

Tested by

no test coverage detected