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

Method close

src/aria/private/menu/menu.ts:906–928  ·  view source on GitHub ↗

Closes the submenu.

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

Source from the content-addressed store, hash-verified

904
905 /** Closes the submenu. */
906 close(opts: {refocus?: boolean} = {}) {
907 this._expanded.set(false);
908 this.pendingFocus.set(null);
909
910 if (opts.refocus) {
911 this.inputs.parent()?.listBehavior.goto(this);
912 }
913
914 let menuitems = this.inputs.submenu()?.inputs.items() ?? [];
915
916 while (menuitems.length) {
917 const menuitem = menuitems.pop();
918 menuitem?._expanded.set(false);
919 menuitem?.inputs.parent()?.listBehavior.unfocus();
920 menuitems = menuitems.concat(menuitem?.submenu()?.inputs.items() ?? []);
921
922 const parent = menuitem?.inputs.parent();
923
924 if (parent instanceof MenuPattern) {
925 parent._clearTimeouts();
926 }
927 }
928 }
929
930 /** Handles focusin events for the menu item. */
931 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