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

Method _handleHover

src/material/menu/menu-trigger.ts:208–226  ·  view source on GitHub ↗

Handles the cases where the user hovers over the trigger.

()

Source from the content-addressed store, hash-verified

206
207 /** Handles the cases where the user hovers over the trigger. */
208 private _handleHover() {
209 // Subscribe to changes in the hovered item in order to toggle the panel.
210 if (this.triggersSubmenu() && this._parentMaterialMenu) {
211 this._hoverSubscription = this._parentMaterialMenu._hovered().subscribe(active => {
212 if (
213 active === this._menuItemInstance &&
214 !active.disabled &&
215 // Ignore hover events if the parent menu is in the process of being closed (see #31956).
216 this._parentMaterialMenu?._panelAnimationState !== 'void'
217 ) {
218 this._openedBy = 'mouse';
219 // Open the menu, but do NOT auto-focus on first item when just hovering.
220 // When VoiceOver is enabled, this is particularly confusing as the focus will
221 // cause another hover event, and continue opening sub-menus without interaction.
222 this._openMenu(false);
223 }
224 });
225 }
226 }
227}

Callers 1

ngAfterContentInitMethod · 0.95

Calls 2

triggersSubmenuMethod · 0.95
_hoveredMethod · 0.80

Tested by

no test coverage detected