Skip to content

Commit

Permalink
CMS-311: Fix advisories accordion expand issue (#1434)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayumi-oxd authored Aug 16, 2024
1 parent 1ff82be commit 152ad47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/gatsby/src/components/park/advisoryDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const formatDate = isoDate => {
return isoDate ? format(parseJSON(isoDate), "MMMM d, yyyy") : ""
}

export default function AdvisoryDetails({ advisories, parkType }) {
export default function AdvisoryDetails({ advisories, parkType, parkAccessStatus }) {
advisories.sort((a, b) => {
return b.listingRank - a.listingRank
|| b?.urgency?.sequence - a?.urgency?.sequence
Expand Down Expand Up @@ -82,10 +82,10 @@ export default function AdvisoryDetails({ advisories, parkType }) {
}, [openAccordions, advisoriesWithFormatting.length])

useEffect(() => {
if (advisoriesWithFormatting.length === 1) {
if (advisoriesWithFormatting.length === 1 && parkAccessStatus !== null) {
setOpenAccordions({ 0: true })
}
}, [advisoriesWithFormatting.length])
}, [advisoriesWithFormatting.length, parkAccessStatus])

return (
<div id="advisories">
Expand Down
2 changes: 1 addition & 1 deletion src/gatsby/src/templates/park.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export default function ParkTemplate({ data }) {
</div>
)}
{!isLoadingAdvisories && !advisoryLoadError && (
<AdvisoryDetails advisories={advisories} parkType={parkType} />
<AdvisoryDetails advisories={advisories} parkType={parkType} parkAccessStatus={parkAccessStatus} />
)}
{hasParkGuidelines &&
<Row>
Expand Down

0 comments on commit 152ad47

Please sign in to comment.