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

Method _handleFocusOut

src/cdk/listbox/listbox.ts:828–840  ·  view source on GitHub ↗

* Called when the focus leaves an element in the listbox. * @param event The focusout event

(event: FocusEvent)

Source from the content-addressed store, hash-verified

826 * @param event The focusout event
827 */
828 protected _handleFocusOut(event: FocusEvent) {
829 // Some browsers (e.g. Chrome and Firefox) trigger the focusout event when the user returns back to the document.
830 // To prevent losing the active option in this case, we store it in `_previousActiveOption` and restore it on the window `blur` event
831 // This ensures that the `activeItem` matches the actual focused element when the user returns to the document.
832 this._previousActiveOption = this.listKeyManager.activeItem;
833
834 const otherElement = event.relatedTarget as Element;
835 if (this.element !== otherElement && !this.element.contains(otherElement)) {
836 this._onTouched();
837 this._hasFocus = false;
838 this._setNextFocusToSelectedOption();
839 }
840 }
841
842 /** Get the id of the active option if active descendant is being used. */
843 protected _getAriaActiveDescendant(): string | null | undefined {

Callers

nothing calls this directly

Calls 2

_onTouchedMethod · 0.80

Tested by

no test coverage detected