From 09bb9ee55d41f89bf55e7a6a54251fa9d86a704b Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Tue, 24 Feb 2026 19:49:04 -0300 Subject: [PATCH] fix(ui): resolve Cannot read properties of null (reading 'appendChild') in window-manager.js - Lazy load workspace and taskbar containers to prevent crashes when WindowManager is instantiated in the head before the body DOM is ready --- ui/suite/js/window-manager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/suite/js/window-manager.js b/ui/suite/js/window-manager.js index bd67225..80198c2 100644 --- a/ui/suite/js/window-manager.js +++ b/ui/suite/js/window-manager.js @@ -4,11 +4,16 @@ if (typeof window.WindowManager === 'undefined') { this.openWindows = []; this.activeWindowId = null; this.zIndexCounter = 100; - this.workspace = document.getElementById('desktop-content') || document.body; - this.taskbarApps = document.getElementById('taskbar-apps'); + // Will fetch dynamically in open() since script runs before DOM is ready + this.workspace = null; + this.taskbarApps = null; } open(id, title, htmlContent) { + // Lazy load the container elements to avoid head script loading issues + if (!this.workspace) this.workspace = document.getElementById('desktop-content') || document.body; + if (!this.taskbarApps) this.taskbarApps = document.getElementById('taskbar-apps'); + // If window already exists, focus it const existingWindow = this.openWindows.find(w => w.id === id); if (existingWindow) {