* Attaches content, given via a Portal, to the overlay. * If the overlay is configured to have a backdrop, it will be created. * * @param portal Portal instance to which to attach the overlay. * @returns The portal attachment result.
(portal: Portal<any>)
| 129 | * @returns The portal attachment result. |
| 130 | */ |
| 131 | attach(portal: Portal<any>): any { |
| 132 | if (this._disposed) { |
| 133 | return null; |
| 134 | } |
| 135 | |
| 136 | // Insert the host into the DOM before attaching the portal, otherwise |
| 137 | // the animations module will skip animations on repeat attachments. |
| 138 | this._attachHost(); |
| 139 | |
| 140 | const attachResult = this._portalOutlet.attach(portal); |
| 141 | this._positionStrategy?.attach(this); |
| 142 | this._updateStackingOrder(); |
| 143 | this._updateElementSize(); |
| 144 | this._updateElementDirection(); |
| 145 | |
| 146 | if (this._scrollStrategy) { |
| 147 | this._scrollStrategy.enable(); |
| 148 | } |
| 149 | |
| 150 | // We need to clean this up ourselves, because we're passing in an |
| 151 | // `EnvironmentInjector` below which won't ever be destroyed. |
| 152 | // Otherwise it causes some callbacks to be retained (see #29696). |
| 153 | this._afterNextRenderRef?.destroy(); |
| 154 | |
| 155 | // Update the position once the overlay is fully rendered before attempting to position it, |
| 156 | // as the position may depend on the size of the rendered content. |
| 157 | this._afterNextRenderRef = afterNextRender( |
| 158 | () => { |
| 159 | // The overlay could've been detached before the callback executed. |
| 160 | if (this.hasAttached()) { |
| 161 | this.updatePosition(); |
| 162 | } |
| 163 | }, |
| 164 | {injector: this._injector}, |
| 165 | ); |
| 166 | |
| 167 | // Enable pointer events for the overlay pane element. |
| 168 | this._togglePointerEvents(true); |
| 169 | |
| 170 | if (this._config.hasBackdrop) { |
| 171 | this._attachBackdrop(); |
| 172 | } |
| 173 | |
| 174 | if (this._config.panelClass) { |
| 175 | this._toggleClasses(this._pane, this._config.panelClass, true); |
| 176 | } |
| 177 | |
| 178 | // Only emit the `attachments` event once all other setup is done. |
| 179 | this._attachments.next(); |
| 180 | this._completeDetachContent(); |
| 181 | |
| 182 | // Track this overlay by the keyboard dispatcher |
| 183 | this._keyboardDispatcher.add(this); |
| 184 | |
| 185 | if (this._config.disposeOnNavigation) { |
| 186 | this._locationChanges = this._location.subscribe(() => this.dispose()); |
| 187 | } |
| 188 |
nothing calls this directly
no test coverage detected