MCPcopy Index your code
hub / github.com/angular/components / closeOpenMenu

Function closeOpenMenu

src/cdk/menu/menu-base.ts:167–183  ·  view source on GitHub ↗

* Close the open menu if the current active item opened the requested MenuStackItem. * @param menu The menu requested to be closed. * @param options Options to configure the behavior on close. * - `focusParentTrigger` Whether to focus the parent trigger after closing the menu.

(menu: MenuStackItem, options?: {focusParentTrigger?: boolean})

Source from the content-addressed store, hash-verified

165 * - `focusParentTrigger` Whether to focus the parent trigger after closing the menu.
166 */
167 protected closeOpenMenu(menu: MenuStackItem, options?: {focusParentTrigger?: boolean}) {
168 const {focusParentTrigger} = {...options};
169 const keyManager = this.keyManager;
170 const trigger = this.triggerItem;
171 if (menu === trigger?.getMenuTrigger()?.getMenu()) {
172 trigger?.getMenuTrigger()?.close();
173 // If the user has moused over a sibling item we want to focus the element under mouse focus
174 // not the trigger which previously opened the now closed menu.
175 if (focusParentTrigger) {
176 if (trigger) {
177 keyManager.setActiveItem(trigger);
178 } else {
179 keyManager.setFirstItemActive();
180 }
181 }
182 }
183 }
184
185 /** Sets up the subscription that keeps the items list in sync. */
186 private _setItems() {

Callers

nothing calls this directly

Calls 5

getMenuTriggerMethod · 0.80
setFirstItemActiveMethod · 0.80
getMenuMethod · 0.65
closeMethod · 0.45
setActiveItemMethod · 0.45

Tested by

no test coverage detected