Skip to content

Commit

Permalink
Merge pull request #620 from namecheap/chore/embedded_app_remove_css
Browse files Browse the repository at this point in the history
chore: add comments about new updates to CssTrackedApp
  • Loading branch information
m2broth authored Oct 16, 2024
2 parents 72cebcb + abc4a09 commit d278b49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ilc/client/CssTrackedApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class CssTrackedApp {
#originalApp;
#cssLinkUri;
#delayCssRemoval;
// used to prevent removing CSS immediately after unmounting
#isRouteChanged = false;
#routeChangeListener;

Expand All @@ -22,8 +23,11 @@ export class CssTrackedApp {
this.#cssLinkUri = cssLink;
this.#delayCssRemoval = delayCssRemoval;

// add route change listener for embedded apps
if (!delayCssRemoval) {
// While CSS for an application rendered by another application is not always immediately necessary upon unmount, there is a non-trivial case to consider:
// - When the route changes and a spinner is enabled in the registry, the root application is unmounted and destroyed.
// - ILC then shows a copy of the previously rendered DOM node.
// - Which leads to a situation where both the root and inner applications unmount synchronously. Despite being unmounted, their styles are still required until the route transition is complete.
this.#addRouteChangeListener();
}
}
Expand Down Expand Up @@ -128,6 +132,7 @@ export class CssTrackedApp {
}

#shouldDelayRemoval() {
// If the route is changing, we should delay CSS removal to prevent visual glitches.
return this.#delayCssRemoval || this.#isRouteChanged;
}

Expand Down

0 comments on commit d278b49

Please sign in to comment.