diff --git a/ilc/client/CssTrackedApp.js b/ilc/client/CssTrackedApp.js index 6781baeb..776fa0a6 100644 --- a/ilc/client/CssTrackedApp.js +++ b/ilc/client/CssTrackedApp.js @@ -4,6 +4,7 @@ export class CssTrackedApp { #originalApp; #cssLinkUri; #delayCssRemoval; + // used to prevent removing CSS immediately after unmounting #isRouteChanged = false; #routeChangeListener; @@ -22,8 +23,10 @@ export class CssTrackedApp { this.#cssLinkUri = cssLink; this.#delayCssRemoval = delayCssRemoval; - // add route change listener for embedded apps if (!delayCssRemoval) { + // In an embedded app, removing CSS immediately after unmounting can cause visual glitches + // while a spinner is loading and the route is changing. Delaying CSS removal until the route + // change is complete ensures styles remain intact during the transition. this.#addRouteChangeListener(); } } @@ -128,6 +131,7 @@ export class CssTrackedApp { } #shouldDelayRemoval() { + // If the route is changing, we should delay CSS removal to prevent visual glitches. return this.#delayCssRemoval || this.#isRouteChanged; }