Detaches the overlay once the content finishes animating and is removed from the DOM.
()
| 521 | |
| 522 | /** Detaches the overlay once the content finishes animating and is removed from the DOM. */ |
| 523 | private _detachContentWhenEmpty() { |
| 524 | let rethrow = false; |
| 525 | // Attempt to detach on the next render. |
| 526 | try { |
| 527 | this._detachContentAfterRenderRef = afterNextRender( |
| 528 | () => { |
| 529 | // Rethrow if we encounter an actual error detaching. |
| 530 | rethrow = true; |
| 531 | this._detachContent(); |
| 532 | }, |
| 533 | { |
| 534 | injector: this._injector, |
| 535 | }, |
| 536 | ); |
| 537 | } catch (e) { |
| 538 | if (rethrow) { |
| 539 | throw e; |
| 540 | } |
| 541 | // afterNextRender throws if the EnvironmentInjector is has already been destroyed. |
| 542 | // This may happen in tests that don't properly flush all async work. |
| 543 | // In order to avoid breaking those tests, we just detach immediately in this case. |
| 544 | this._detachContent(); |
| 545 | } |
| 546 | // Otherwise wait until the content finishes animating out and detach. |
| 547 | if (globalThis.MutationObserver && this._pane) { |
| 548 | this._detachContentMutationObserver ||= new globalThis.MutationObserver(() => { |
| 549 | this._detachContent(); |
| 550 | }); |
| 551 | this._detachContentMutationObserver.observe(this._pane, {childList: true}); |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | private _detachContent() { |
| 556 | // Needs a couple of checks for the pane and host, because |
no test coverage detected