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

Method detach

src/cdk/overlay/overlay-ref.ts:235–275  ·  view source on GitHub ↗

* Detaches an overlay from a portal. * @returns The portal detachment result.

()

Source from the content-addressed store, hash-verified

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 {

Callers 1

attachMethod · 0.95

Calls 11

hasAttachedMethod · 0.95
detachBackdropMethod · 0.95
_togglePointerEventsMethod · 0.95
detachMethod · 0.65
removeMethod · 0.65
updateMethod · 0.65
disableMethod · 0.45
nextMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected