From f0953a957a3042186911353f1066afb64b301088 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Fri, 16 Dec 2022 21:13:29 -0800 Subject: [PATCH] Fix exception with appearance reset. Closes #2459 --- web/pages/admin/config/appearance/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/pages/admin/config/appearance/index.tsx b/web/pages/admin/config/appearance/index.tsx index 3fe8556d7..84e2df234 100644 --- a/web/pages/admin/config/appearance/index.tsx +++ b/web/pages/admin/config/appearance/index.tsx @@ -107,7 +107,7 @@ export default function Appearance() { clearTimeout(resetTimer); }; - useEffect(() => { + const setColorDefaults = () => { const c = {}; [...paletteVariables, ...componentColorVariables, ...chatColorVariables].forEach(color => { const resolvedColor = getComputedStyle(document.documentElement).getPropertyValue( @@ -116,6 +116,10 @@ export default function Appearance() { c[color.name] = { value: resolvedColor.trim(), description: color.description }; }); setColors(c); + }; + + useEffect(() => { + setColorDefaults(); }, []); useEffect(() => { @@ -136,13 +140,13 @@ export default function Appearance() { }; const reset = async () => { - setColors({}); await postConfigUpdateToAPI({ apiPath: ENDPOINT, data: { value: {} }, onSuccess: () => { setSubmitStatus(createInputStatus(STATUS_SUCCESS, 'Updated.')); resetTimer = setTimeout(resetStates, RESET_TIMEOUT); + setColorDefaults(); }, onError: (message: string) => { setSubmitStatus(createInputStatus(STATUS_ERROR, message));