Class: FyzMenuTrigger
@flyze/lib-core-angular 1.0.0-alpha.34· latestDefined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:30
A directive that extends the MatMenuTrigger to provide additional functionality.
Extends
Section titled “Extends”MatMenuTrigger
Implements
Section titled “Implements”OnInit
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FyzMenuTrigger(
overlay,element,viewContainerRef,scrollStrategy,parentMenu,menuItemInstance,dir,focusMonitor,ngZone):FyzMenuTrigger
Defined in: node_modules/@angular/material/menu/index.d.ts:476
Parameters
Section titled “Parameters”overlay
Section titled “overlay”Overlay
element
Section titled “element”ElementRef<HTMLElement>
viewContainerRef
Section titled “viewContainerRef”ViewContainerRef
scrollStrategy
Section titled “scrollStrategy”any
parentMenu
Section titled “parentMenu”MatMenuPanel
menuItemInstance
Section titled “menuItemInstance”MatMenuItem
Directionality
focusMonitor
Section titled “focusMonitor”FocusMonitor
ngZone
Section titled “ngZone”NgZone
Returns
Section titled “Returns”FyzMenuTrigger
Inherited from
Section titled “Inherited from”MatMenuTrigger.constructor
Constructor
Section titled “Constructor”new FyzMenuTrigger(
overlay,element,viewContainerRef,scrollStrategy,parentMenu,menuItemInstance,dir,focusMonitor?):FyzMenuTrigger
Defined in: node_modules/@angular/material/menu/index.d.ts:481
Parameters
Section titled “Parameters”overlay
Section titled “overlay”Overlay
element
Section titled “element”ElementRef<HTMLElement>
viewContainerRef
Section titled “viewContainerRef”ViewContainerRef
scrollStrategy
Section titled “scrollStrategy”any
parentMenu
Section titled “parentMenu”MatMenuPanel
menuItemInstance
Section titled “menuItemInstance”MatMenuItem
Directionality
focusMonitor?
Section titled “focusMonitor?”FocusMonitor
Returns
Section titled “Returns”FyzMenuTrigger
Deprecated
Section titled “Deprecated”focusMonitor will become a required parameter.
Breaking-change
Section titled “Breaking-change”8.0.0
Inherited from
Section titled “Inherited from”MatMenuTrigger.constructor
Constructor
Section titled “Constructor”new FyzMenuTrigger(
overlay,element,viewContainerRef,scrollStrategy,parentMenu,menuItemInstance,dir,focusMonitor):FyzMenuTrigger
Defined in: node_modules/@angular/material/menu/index.d.ts:486
Parameters
Section titled “Parameters”overlay
Section titled “overlay”Overlay
element
Section titled “element”ElementRef<HTMLElement>
viewContainerRef
Section titled “viewContainerRef”ViewContainerRef
scrollStrategy
Section titled “scrollStrategy”any
parentMenu
Section titled “parentMenu”MatMenuPanel
menuItemInstance
Section titled “menuItemInstance”MatMenuItem
Directionality
focusMonitor
Section titled “focusMonitor”FocusMonitor
Returns
Section titled “Returns”FyzMenuTrigger
Deprecated
Section titled “Deprecated”ngZone will become a required parameter.
Breaking-change
Section titled “Breaking-change”15.0.0
Inherited from
Section titled “Inherited from”MatMenuTrigger.constructor
Accessors
Section titled “Accessors”anchor
Section titled “anchor”Get Signature
Section titled “Get Signature”get anchor():
HTMLElement
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:115
The element the menu is anchored to on every open, instead of the directive’s host element. Use it when the trigger sits inside a wrapper the menu should line up with - a chips container around a search input, for example, where anchoring to the input alone would let the menu drift sideways as chips push the input along.
openMenuAtElement() still wins for the single open it applies to.
Returns
Section titled “Returns”HTMLElement
Set Signature
Section titled “Set Signature”set anchor(
value):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:118
Parameters
Section titled “Parameters”HTMLElement | ElementRef<HTMLElement>
Returns
Section titled “Returns”void
closeOnScrollOutOfView
Section titled “closeOnScrollOutOfView”Get Signature
Section titled “Get Signature”get closeOnScrollOutOfView():
unknown
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:98
Whether the menu should close once its trigger has been scrolled out of sight. Without it the menu keeps following the trigger and is clamped to the viewport.
Returns
Section titled “Returns”unknown
Set Signature
Section titled “Set Signature”set closeOnScrollOutOfView(
value):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:101
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”void
Get Signature
Section titled “Get Signature”get gap():
number
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:85
The gap between the menu and the trigger element.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set gap(
value):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:88
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Get Signature
Section titled “Get Signature”get menu():
MatMenuPanel<any>
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:165
References the menu instance that the trigger is associated with.
Returns
Section titled “Returns”MatMenuPanel<any>
Set Signature
Section titled “Set Signature”set menu(
menu):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:168
References the menu instance that the trigger is associated with.
Parameters
Section titled “Parameters”MatMenuPanel
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”MatMenuTrigger.menu
openOnClick
Section titled “openOnClick”Get Signature
Section titled “Get Signature”get openOnClick():
unknown
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:132
Whether a click on the trigger opens the menu. true is Material’s own behavior.
Set it to false to link a menu to this trigger without the directive opening it: the ARIA
wiring and the positioning stay in place, and the consumer decides when to call openMenu().
That is what a combobox needs - Material toggles on click, so an open panel would close again
when the user clicks the input to move the caret.
Returns
Section titled “Returns”unknown
Set Signature
Section titled “Set Signature”set openOnClick(
value):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:135
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”void
panelWidth
Section titled “panelWidth”Get Signature
Section titled “Get Signature”get panelWidth():
"anchor"
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:154
The width of the menu panel.
'anchor'- exactly as wide as the element the menu attaches to, from the first open, and it keeps following that element while the menu is open. Also drops the defaultviewportMarginto0, so the menu stays on its origin even flush against the window edge.null(default) - the directive does nothing. Material’s own112px-280pxpanel sizing stands, exactly as it does on a plainmatMenuTrigger.
Which element 'anchor' measures is whatever the origin resolves to: openMenuAtElement(),
then the anchor input, then the host. A menu opened with openMenuAt(x, y) has no origin
element and is unaffected.
Returns
Section titled “Returns”"anchor"
Set Signature
Section titled “Set Signature”set panelWidth(
value):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:157
Parameters
Section titled “Parameters”"anchor"
Returns
Section titled “Returns”void
viewportMargin
Section titled “viewportMargin”Get Signature
Section titled “Get Signature”get viewportMargin():
number
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:73
The margin around the viewport where the menu should be positioned.
Defaults to 8, or to 0 when panelWidth is 'anchor' - a menu exactly as wide as its
origin is on screen whenever that origin is, and the margin is what would otherwise shift it
off an origin flush against the window edge. Setting the input explicitly always wins.
The CDK spends the margin unevenly - it is the trailing/bottom distance, doubled, and the leading edges get none. See docs/features/mat-menu-trigger.md.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set viewportMargin(
value):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:76
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Methods
Section titled “Methods”_handleClick()
Section titled “_handleClick()”_handleClick(
event):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:240
Swallows the click when openOnClick is off.
Unlike _setPosition, this one is public in Material’s type, so it is a real override - a
signature change on upgrade fails the build instead of silently doing nothing. It is reached
because Angular copies Material’s host listeners onto this directive and dispatches them on
the instance.
Parameters
Section titled “Parameters”MouseEvent
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”MatMenuTrigger._handleClick
ngOnDestroy()
Section titled “ngOnDestroy()”ngOnDestroy():
void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:177
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”MatMenuTrigger.ngOnDestroy
ngOnInit()
Section titled “ngOnInit()”ngOnInit():
void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:172
A callback method that is invoked immediately after the default change detector has checked the directive’s data-bound properties for the first time, and before any of the view or content children have been checked. It is invoked only once when the directive is instantiated.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”OnInit.ngOnInit
openMenu()
Section titled “openMenu()”openMenu():
void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:200
Material’s own open, plus the two things panelWidth needs and cannot do any earlier.
Both of them have to happen after super.openMenu():
- the pane is sized here rather than from inside
_setPosition, becauseupdateSize()replacesOverlayRef._config(overlay.mjs:939) whileopenMenu()captured that object before calling_setPositionand writeshasBackdropto it afterwards (menu.mjs:840). Replacing it in between orphans that write,attach()readsundefined, no backdrop is created - andbackdropClick()is the only thing that closes a menu on an outside click. - the panel inside the pane only exists once
attach()has run. Sizing the pane is not enough on its own:.cdk-overlay-paneis a row flexbox, so the panel does not stretch to it, and.mat-mdc-menu-panelcarriesmin-width: 112px; max-width: 280px.
Doing this after the open costs nothing: OverlayRef.attach() defers positioning to
NgZone.onStable (overlay.mjs:793), so the width is still in the DOM before the CDK measures.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”MatMenuTrigger.openMenu
openMenuAt()
Section titled “openMenuAt()”openMenuAt(
x,y):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:336
Open the menu at the specified coordinates.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”void
openMenuAtElement()
Section titled “openMenuAtElement()”openMenuAtElement(
element):void
Defined in: projects/lib-core-angular/src/lib/directives/fyz-mat-menu-trigger/fyz-mat-menu-trigger.directive.ts:347
Opens the menu at the specified element.
Parameters
Section titled “Parameters”element
Section titled “element”HTMLElement
Returns
Section titled “Returns”void