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
This commit is contained in:
parent
6d07aa4bdd
commit
09bb9ee55d
1 changed files with 7 additions and 2 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue