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

Method onFocusOut

src/aria/private/menu/menu.ts:329–357  ·  view source on GitHub ↗

Handles the focusout event for the menu.

(event: FocusEvent)

Source from the content-addressed store, hash-verified

327
328 /** Handles the focusout event for the menu. */
329 onFocusOut(event: FocusEvent) {
330 const parent = this.inputs.parent();
331 const parentEl = parent?.inputs.element();
332 const relatedTarget = event.relatedTarget as Node | null;
333
334 if (!relatedTarget) {
335 this.isFocused.set(false);
336 this.inputs.parent()?.close({refocus: true});
337 }
338
339 if (parent instanceof MenuItemPattern) {
340 const grandparent = parent.inputs.parent();
341 const siblings = grandparent?.inputs.items().filter(i => i !== parent);
342 const item = siblings?.find(i => i.element()?.contains(relatedTarget));
343
344 if (item) {
345 return;
346 }
347 }
348
349 if (
350 this.visible() &&
351 !parentEl?.contains(relatedTarget) &&
352 !this.inputs.element()?.contains(relatedTarget)
353 ) {
354 this.isFocused.set(false);
355 this.inputs.parent()?.close();
356 }
357 }
358
359 /** Focuses the previous menu item. */
360 prev() {

Callers 1

menu.spec.tsFile · 0.45

Calls 6

parentMethod · 0.80
setMethod · 0.80
visibleMethod · 0.80
elementMethod · 0.45
closeMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected