From 256ea18bd9b1432bd07249be11061a2edc31483d Mon Sep 17 00:00:00 2001 From: mikyll Date: Tue, 11 Nov 2025 16:28:01 +0100 Subject: [PATCH 1/5] fix(color): invalid theme fallback to default Fixes: #4641 --- src/common/color.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/color.js b/src/common/color.js index a372f24401a9a..fe82a433ed43b 100644 --- a/src/common/color.js +++ b/src/common/color.js @@ -83,7 +83,7 @@ const getCardColors = ({ theme, }) => { const defaultTheme = themes["default"]; - const isThemeProvided = theme !== null && theme !== undefined; + const isThemeProvided = theme !== null && theme !== undefined && themes.hasOwnProperty(theme); // @ts-ignore const selectedTheme = isThemeProvided ? themes[theme] : defaultTheme; @@ -92,7 +92,7 @@ const getCardColors = ({ "border_color" in selectedTheme ? selectedTheme.border_color : // @ts-ignore - defaultTheme.border_color; + defaultTheme.border_color; // get the color provided by the user else the theme color // finally if both colors are invalid fallback to default theme From 014064fe63b0d234a75af072ef29a70ec2350e76 Mon Sep 17 00:00:00 2001 From: mikyll Date: Tue, 11 Nov 2025 16:28:23 +0100 Subject: [PATCH 2/5] test(color): add test case for invalid theme fallback to default --- tests/color.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/color.test.js b/tests/color.test.js index 9fc6d067794ad..b1b2a80998e77 100644 --- a/tests/color.test.js +++ b/tests/color.test.js @@ -73,4 +73,19 @@ describe("Test color.js", () => { borderColor: "#fff", }); }); + + it("getCardColors: should fallback to default theme if theme is invalid", () => { + let colors = getCardColors({ + theme: "invalidTheme", + }); + expect(colors).toStrictEqual({ + titleColor: "#2f80ed", + textColor: "#0f0", + iconColor: "#00f", + ringColor: "#2f80ed", + bgColor: "#fff", + borderColor: "#e4e2e2", + theme: "default", + }); + }); }); From 172f4bf8bda50d8352bad06551697449e63dd211 Mon Sep 17 00:00:00 2001 From: mikyll Date: Tue, 11 Nov 2025 16:51:51 +0100 Subject: [PATCH 3/5] style(color): add back the tab space --- src/common/color.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/color.js b/src/common/color.js index fe82a433ed43b..92d8792b03159 100644 --- a/src/common/color.js +++ b/src/common/color.js @@ -92,7 +92,7 @@ const getCardColors = ({ "border_color" in selectedTheme ? selectedTheme.border_color : // @ts-ignore - defaultTheme.border_color; + defaultTheme.border_color; // get the color provided by the user else the theme color // finally if both colors are invalid fallback to default theme From 9393b908a5474c6fe366c339a0f3472aa7490427 Mon Sep 17 00:00:00 2001 From: mikyll Date: Tue, 11 Nov 2025 16:54:28 +0100 Subject: [PATCH 4/5] test(color): fix color default theme --- tests/color.test.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/color.test.js b/tests/color.test.js index b1b2a80998e77..20d52aae767de 100644 --- a/tests/color.test.js +++ b/tests/color.test.js @@ -80,10 +80,9 @@ describe("Test color.js", () => { }); expect(colors).toStrictEqual({ titleColor: "#2f80ed", - textColor: "#0f0", - iconColor: "#00f", - ringColor: "#2f80ed", - bgColor: "#fff", + textColor: "#434d58", + iconColor: "#4c71f2", + bgColor: "#fffefe", borderColor: "#e4e2e2", theme: "default", }); From 7fbae290d569744763cfcd7c26f0979d5607d585 Mon Sep 17 00:00:00 2001 From: mikyll Date: Mon, 17 Nov 2025 14:05:07 +0100 Subject: [PATCH 5/5] fix(color): use 'in' instead of '.hasOwnProperty' --- src/common/color.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/color.js b/src/common/color.js index 92d8792b03159..61704170f565d 100644 --- a/src/common/color.js +++ b/src/common/color.js @@ -83,7 +83,7 @@ const getCardColors = ({ theme, }) => { const defaultTheme = themes["default"]; - const isThemeProvided = theme !== null && theme !== undefined && themes.hasOwnProperty(theme); + const isThemeProvided = theme !== null && theme !== undefined && theme in themes; // @ts-ignore const selectedTheme = isThemeProvided ? themes[theme] : defaultTheme;