From d2acaa49ee8689cff7b505435cc94356c1d39f97 Mon Sep 17 00:00:00 2001 From: seaerchin Date: Wed, 13 Sep 2023 14:12:04 +0800 Subject: [PATCH 1/3] fix(herobody): solves empty highlight deafult issue --- src/layouts/EditHomepage/EditHomepage.jsx | 5 +++++ src/layouts/components/Homepage/HeroBody.tsx | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/layouts/EditHomepage/EditHomepage.jsx b/src/layouts/EditHomepage/EditHomepage.jsx index c78926733..d4a40347d 100644 --- a/src/layouts/EditHomepage/EditHomepage.jsx +++ b/src/layouts/EditHomepage/EditHomepage.jsx @@ -960,6 +960,11 @@ const EditHomepage = ({ match }) => { handleHighlightDropdownToggle={ handleHighlightDropdownToggle } + initialSectionType={ + section.hero.key_highlights + ? "highlights" + : "dropdown" + } > {({ currentSelectedOption }) => currentSelectedOption === "dropdown" ? ( diff --git a/src/layouts/components/Homepage/HeroBody.tsx b/src/layouts/components/Homepage/HeroBody.tsx index 038540a79..a63aadfc3 100644 --- a/src/layouts/components/Homepage/HeroBody.tsx +++ b/src/layouts/components/Homepage/HeroBody.tsx @@ -51,6 +51,7 @@ interface HeroBodyProps extends HeroBodyFormFields { children: (props: { currentSelectedOption: HeroSectionType }) => React.ReactNode + initialSectionType: HeroSectionType } export const HeroBody = ({ @@ -62,9 +63,10 @@ export const HeroBody = ({ handleHighlightDropdownToggle, notification, children, + initialSectionType, }: HeroBodyProps) => { const [heroSectionType, setHeroSectionType] = useState( - "highlights" + initialSectionType ) const { onChange } = useEditableContext() @@ -147,7 +149,7 @@ export const HeroBody = ({ }, }) }} - defaultValue="highlights" + defaultValue={initialSectionType} > Date: Wed, 13 Sep 2023 17:46:34 +0800 Subject: [PATCH 2/3] fix: add default for hero dropdown --- src/layouts/components/Homepage/HeroDropdownSection.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/components/Homepage/HeroDropdownSection.tsx b/src/layouts/components/Homepage/HeroDropdownSection.tsx index 0a786af29..acf00cf23 100644 --- a/src/layouts/components/Homepage/HeroDropdownSection.tsx +++ b/src/layouts/components/Homepage/HeroDropdownSection.tsx @@ -31,7 +31,7 @@ interface HeroDropdownSectionProps extends EditorHeroDropdownSection { export const HeroDropdownSection = ({ errors, - dropdown, + dropdown = { options: [] }, title, }: HeroDropdownSectionProps) => { const { From 38eafe9c2f77c1c7f217a0880a4be4bb9f166dd6 Mon Sep 17 00:00:00 2001 From: Alexander Lee Date: Wed, 13 Sep 2023 17:47:13 +0800 Subject: [PATCH 3/3] chore: swap intialSectionType selector to follow conditional --- src/layouts/EditHomepage/EditHomepage.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/layouts/EditHomepage/EditHomepage.jsx b/src/layouts/EditHomepage/EditHomepage.jsx index d4a40347d..cf7a361c0 100644 --- a/src/layouts/EditHomepage/EditHomepage.jsx +++ b/src/layouts/EditHomepage/EditHomepage.jsx @@ -961,9 +961,9 @@ const EditHomepage = ({ match }) => { handleHighlightDropdownToggle } initialSectionType={ - section.hero.key_highlights - ? "highlights" - : "dropdown" + section.hero.dropdown + ? "dropdown" + : "highlights" } > {({ currentSelectedOption }) =>