From 54985bf69020908689ad1e83511201f84cffbba2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Apr 2026 12:56:10 +0000 Subject: [PATCH] Fix crash in popped-out window when a theme is missing a color Window.setWindowBackgroundColor was crashing with "Cannot read properties of undefined (reading 'replace')" when called with an undefined color, which happened in popped-out editor windows when switching to a theme that doesn't define its toolbar background color. Now skip the update instead of crashing. https://claude.ai/code/session_01DJ6TnzwSweCWS7LaRd2E2b --- newIDE/app/src/Utils/Window.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/newIDE/app/src/Utils/Window.js b/newIDE/app/src/Utils/Window.js index 243891f5b7fc..85f2faf6a059 100644 --- a/newIDE/app/src/Utils/Window.js +++ b/newIDE/app/src/Utils/Window.js @@ -125,6 +125,13 @@ export default class Window { static setWindowBackgroundColor(newColor: string, targetDocument?: Document) { const doc = targetDocument || document; + if (!newColor) { + // Be defensive against themes missing a color (for instance, a + // newly added variable that an older or custom theme doesn't define): + // skip the update rather than crashing. + return; + } + if (documentBackgroundColors.get(doc) === newColor) { // Avoid potentially expensive DOM query/modification if no changes needed. return;