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

Method _handleMousedown

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

Handles mouse presses on the trigger.

(event: MouseEvent)

Source from the content-addressed store, hash-verified

160
161 /** Handles mouse presses on the trigger. */
162 _handleMousedown(event: MouseEvent): void {
163 if (!isFakeMousedownFromScreenReader(event)) {
164 // Since right or middle button clicks won't trigger the `click` event,
165 // we shouldn't consider the menu as opened by mouse in those cases.
166 this._openedBy = event.button === 0 ? 'mouse' : undefined;
167
168 // Since clicking on the trigger won't close the menu if it opens a sub-menu,
169 // we should prevent focus from moving onto it via click to avoid the
170 // highlight from lingering on the menu item.
171 if (this.triggersSubmenu()) {
172 event.preventDefault();
173 }
174 }
175 }
176
177 /** Handles key presses on the trigger. */
178 _handleKeydown(event: KeyboardEvent): void {

Callers

nothing calls this directly

Calls 2

triggersSubmenuMethod · 0.95

Tested by

no test coverage detected