Skip to content

Commit

Permalink
fix(herobody): solves empty highlight deafult issue (#1489)
Browse files Browse the repository at this point in the history
* fix(herobody): solves empty highlight deafult issue

* fix: add default for hero dropdown

* chore: swap intialSectionType selector to follow conditional

---------

Co-authored-by: seaerchin <[email protected]>
Co-authored-by: Alexander Lee <[email protected]>
  • Loading branch information
3 people authored Sep 13, 2023
1 parent bbaaf81 commit 140afeb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/layouts/EditHomepage/EditHomepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,11 @@ const EditHomepage = ({ match }) => {
handleHighlightDropdownToggle={
handleHighlightDropdownToggle
}
initialSectionType={
section.hero.dropdown
? "dropdown"
: "highlights"
}
>
{({ currentSelectedOption }) =>
currentSelectedOption === "dropdown" ? (
Expand Down
6 changes: 4 additions & 2 deletions src/layouts/components/Homepage/HeroBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface HeroBodyProps extends HeroBodyFormFields {
children: (props: {
currentSelectedOption: HeroSectionType
}) => React.ReactNode
initialSectionType: HeroSectionType
}

export const HeroBody = ({
Expand All @@ -62,9 +63,10 @@ export const HeroBody = ({
handleHighlightDropdownToggle,
notification,
children,
initialSectionType,
}: HeroBodyProps) => {
const [heroSectionType, setHeroSectionType] = useState<HeroSectionType>(
"highlights"
initialSectionType
)
const { onChange } = useEditableContext()

Expand Down Expand Up @@ -147,7 +149,7 @@ export const HeroBody = ({
},
})
}}
defaultValue="highlights"
defaultValue={initialSectionType}
>
<HStack spacing="2rem">
<Radio
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/components/Homepage/HeroDropdownSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface HeroDropdownSectionProps extends EditorHeroDropdownSection {

export const HeroDropdownSection = ({
errors,
dropdown,
dropdown = { options: [] },
title,
}: HeroDropdownSectionProps) => {
const {
Expand Down

0 comments on commit 140afeb

Please sign in to comment.