* Open the attached menu at the specified location. * @param userEvent User-generated event that opened the menu * @param coordinates where to open the context menu
(userEvent: MouseEvent | null, coordinates: ContextMenuCoordinates)
| 208 | * @param coordinates where to open the context menu |
| 209 | */ |
| 210 | private _open(userEvent: MouseEvent | null, coordinates: ContextMenuCoordinates) { |
| 211 | if (this.disabled) { |
| 212 | return; |
| 213 | } |
| 214 | if (this.isOpen()) { |
| 215 | // since we're moving this menu we need to close any submenus first otherwise they end up |
| 216 | // disconnected from this one. |
| 217 | this.menuStack.closeSubMenuOf(this.childMenu!); |
| 218 | |
| 219 | ( |
| 220 | this.overlayRef!.getConfig().positionStrategy as FlexibleConnectedPositionStrategy |
| 221 | ).setOrigin(coordinates); |
| 222 | this.overlayRef!.updatePosition(); |
| 223 | } else { |
| 224 | this.opened.next(); |
| 225 | |
| 226 | if (this.overlayRef) { |
| 227 | ( |
| 228 | this.overlayRef.getConfig().positionStrategy as FlexibleConnectedPositionStrategy |
| 229 | ).setOrigin(coordinates); |
| 230 | this.overlayRef.updatePosition(); |
| 231 | } else { |
| 232 | this.overlayRef = createOverlayRef(this._injector, this._getOverlayConfig(coordinates)); |
| 233 | } |
| 234 | |
| 235 | this.overlayRef.attach(this.getMenuContentPortal()); |
| 236 | this._subscribeToOutsideClicks(userEvent); |
| 237 | } |
| 238 | } |
| 239 | } |
no test coverage detected