From dac4e862b816b9ae6aee0dcc0c0be469d1966a9b Mon Sep 17 00:00:00 2001 From: Aadhar Chandiwala Date: Thu, 17 Mar 2022 19:42:26 +0530 Subject: [PATCH 1/2] Fix-Crash on Entering Primary Color Hex Code without # Prefix --- client/components/build/RightSidebar/sections/Theme.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/components/build/RightSidebar/sections/Theme.tsx b/client/components/build/RightSidebar/sections/Theme.tsx index af1883865..7f0966d0d 100644 --- a/client/components/build/RightSidebar/sections/Theme.tsx +++ b/client/components/build/RightSidebar/sections/Theme.tsx @@ -19,6 +19,9 @@ const Theme = () => { const { background, text, primary } = useAppSelector((state) => get(state.resume, 'metadata.theme')); const handleChange = (property: string, color: string) => { + if (color[0] !== '#') { + color = `#${color}`; + } dispatch(setResumeState({ path: `metadata.theme.${property}`, value: color })); }; From e4950728d8b4f886e7e9842c9fc3497d1fd938fb Mon Sep 17 00:00:00 2001 From: Aadhar Chandiwala Date: Fri, 18 Mar 2022 06:18:17 +0530 Subject: [PATCH 2/2] Refactored- Avoiding modifying the prop --- client/components/build/RightSidebar/sections/Theme.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/client/components/build/RightSidebar/sections/Theme.tsx b/client/components/build/RightSidebar/sections/Theme.tsx index 7f0966d0d..80e731080 100644 --- a/client/components/build/RightSidebar/sections/Theme.tsx +++ b/client/components/build/RightSidebar/sections/Theme.tsx @@ -19,10 +19,7 @@ const Theme = () => { const { background, text, primary } = useAppSelector((state) => get(state.resume, 'metadata.theme')); const handleChange = (property: string, color: string) => { - if (color[0] !== '#') { - color = `#${color}`; - } - dispatch(setResumeState({ path: `metadata.theme.${property}`, value: color })); + dispatch(setResumeState({ path: `metadata.theme.${property}`, value: color[0] !== '#' ? `#${color}` : color })); }; return (