MCPcopy Index your code
hub / github.com/angular/components / detach

Method detach

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

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

()

Source from the content-addressed store, hash-verified

215 * @returns The portal detachment result.
216 */
217 detach(): any {
218 if (!this.hasAttached()) {
219 return;
220 }
221
222 this.detachBackdrop();
223
224 // When the overlay is detached, the pane element should disable pointer events.
225 // This is necessary because otherwise the pane element will cover the page and disable
226 // pointer events therefore. Depends on the position strategy and the applied pane boundaries.
227 this._togglePointerEvents(false);
228
229 if (this._positionStrategy && this._positionStrategy.detach) {
230 this._positionStrategy.detach();
231 }
232
233 if (this._scrollStrategy) {
234 this._scrollStrategy.disable();
235 }
236
237 const detachmentResult = this._portalOutlet.detach();
238
239 // Only emit after everything is detached.
240 this._detachments.next();
241 this._completeDetachContent();
242
243 // Remove this overlay from keyboard dispatcher tracking.
244 this._keyboardDispatcher.remove(this);
245
246 // Keeping the host element in the DOM can cause scroll jank, because it still gets
247 // rendered, even though it's transparent and unclickable which is why we remove it.
248 this._detachContentWhenEmpty();
249 this._locationChanges.unsubscribe();
250 this._outsideClickDispatcher.remove(this);
251 return detachmentResult;
252 }
253
254 /** Cleans up the overlay from the DOM. */
255 dispose(): void {

Callers 1

attachMethod · 0.95

Calls 9

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

Tested by

no test coverage detected