From 8ba2fe2777b05cd1bd68ef79dca7bebc087674c2 Mon Sep 17 00:00:00 2001 From: TSC <112517630+LucianoCirino@users.noreply.github.com> Date: Thu, 7 Sep 2023 22:54:47 -0500 Subject: [PATCH] Improve Compatability with Nested Nodes --- js/appearance.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/appearance.js b/js/appearance.js index cb15850..5ea8599 100644 --- a/js/appearance.js +++ b/js/appearance.js @@ -63,6 +63,7 @@ let colorKeys = Object.keys(COLOR_THEMES).filter(key => key !== "none"); shuffleArray(colorKeys); // Shuffle the color themes initially function setNodeColors(node, theme) { + if (!theme) {return;} node.shape = "box"; if(theme.nodeColor && theme.nodeBgColor) { node.color = theme.nodeColor; @@ -79,9 +80,10 @@ const ext = { let colorKey = NODE_COLORS[title]; if (colorKey === "random") { - if (colorKeys.length === 0) { - colorKeys = Object.values(COLOR_THEMES).filter(theme => theme.nodeColor && theme.nodeBgColor); - shuffleArray(colorKeys); // Reshuffle when out of colors + // Check for a valid color key before popping + if (colorKeys.length === 0 || !COLOR_THEMES[colorKeys[colorKeys.length - 1]]) { + colorKeys = Object.keys(COLOR_THEMES).filter(key => key !== "none"); + shuffleArray(colorKeys); } colorKey = colorKeys.pop(); }