same fix for main

This commit is contained in:
André Michelle
2026-03-19 17:44:05 +01:00
parent eb0f5146dd
commit 867ea4c634
@@ -396,7 +396,10 @@ export class StudioService implements ProjectEnv {
const previousScreen = this.#activeCodeEditor.map(state => state.previousScreen).unwrapOrNull()
this.#activeCodeEditor.clear()
if (this.layout.screen.getValue() === "code") {
this.layout.screen.setValue(previousScreen ?? "default")
// Defer the screen switch to avoid cascading UI updates during synchronous
// box deletion. Switching the screen triggers DevicePanel re-evaluation which
// clears mounts before remaining pointerHub onRemoved events have finished.
queueMicrotask(() => this.layout.screen.setValue(previousScreen ?? "default"))
}
}