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

Method close

src/aria/private/menu/menu.ts:897–919  ·  view source on GitHub ↗

Closes the submenu.

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

Source from the content-addressed store, hash-verified

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