* Detaches an overlay from a portal. * @returns The portal detachment result.
()
| 233 | * @returns The portal detachment result. |
| 234 | */ |
| 235 | detach(): any { |
| 236 | if (!this.hasAttached()) { |
| 237 | return; |
| 238 | } |
| 239 | |
| 240 | this.detachBackdrop(); |
| 241 | |
| 242 | // When the overlay is detached, the pane element should disable pointer events. |
| 243 | // This is necessary because otherwise the pane element will cover the page and disable |
| 244 | // pointer events therefore. Depends on the position strategy and the applied pane boundaries. |
| 245 | this._togglePointerEvents(false); |
| 246 | |
| 247 | if (this._positionStrategy && this._positionStrategy.detach) { |
| 248 | this._positionStrategy.detach(); |
| 249 | } |
| 250 | |
| 251 | if (this._scrollStrategy) { |
| 252 | this._scrollStrategy.disable(); |
| 253 | } |
| 254 | |
| 255 | const detachmentResult = this._portalOutlet.detach(); |
| 256 | |
| 257 | // Only emit after everything is detached. |
| 258 | this._detachments.next(); |
| 259 | this._completeDetachContent(); |
| 260 | |
| 261 | // Remove this overlay from keyboard dispatcher tracking. |
| 262 | this._keyboardDispatcher.remove(this); |
| 263 | |
| 264 | // Keeping the host element in the DOM can cause scroll jank, because it still gets |
| 265 | // rendered, even though it's transparent and unclickable which is why we remove it. |
| 266 | this._detachContentWhenEmpty(); |
| 267 | this._locationChanges?.(); |
| 268 | this._outsideClickDispatcher.remove(this); |
| 269 | |
| 270 | untracked(() => { |
| 271 | attachedOverlaysInternal.update(prev => prev.filter(o => o !== this)); |
| 272 | }); |
| 273 | |
| 274 | return detachmentResult; |
| 275 | } |
| 276 | |
| 277 | /** Cleans up the overlay from the DOM. */ |
| 278 | dispose(): void { |
no test coverage detected