diff --git a/components/elements/FAQAccordion.js b/components/elements/FAQAccordion.js index f7cc29e..943e73a 100644 --- a/components/elements/FAQAccordion.js +++ b/components/elements/FAQAccordion.js @@ -2,61 +2,69 @@ import { useState, useRef, useEffect } from 'react'; export default function FAQAccordion({ faqs = [], className = '' }) { - const [activeIndex, setActiveIndex] = useState(null); + const [activeIndex, setActiveIndex] = useState(0); const refs = useRef([]); useEffect(() => { refs.current = refs.current.slice(0, faqs.length); }, [faqs]); + useEffect(() => { + if (faqs.length > 0) { + setTimeout(() => { + setActiveIndex(0); + }, 100); + } + }, [faqs.length]); + if (!faqs || faqs.length === 0) return null; return (
-
- {/*
FAQ
*/} -

FAQs

- {/*
*/} -
+
+ {/*
FAQ
*/} +

FAQs

+ {/*
*/} +
-
- {faqs.map((item, i) => ( -
+ {faqs.map((item, i) => ( +
+ +

{item.q}

+ + -
(refs.current[i] = el)} - className="faq-answer" - style={{ - maxHeight: - activeIndex === i - ? `${refs.current[i]?.scrollHeight || 0}px` - : "0px", - overflow: "hidden", - transition: "max-height 0.4s ease", - }} - aria-hidden={activeIndex !== i} - > -
-

-

+
(refs.current[i] = el)} + className="faq-answer" + style={{ + maxHeight: + activeIndex === i + ? "1000px" + : "0px", + overflow: "hidden", + transition: "max-height 0.4s ease", + }} + aria-hidden={activeIndex !== i} + > +
+

- ))} -
+
+ ))} +
); } diff --git a/utils/constant.utils.js b/utils/constant.utils.js index 5241ae8..63e82ca 100644 --- a/utils/constant.utils.js +++ b/utils/constant.utils.js @@ -5607,8 +5607,8 @@ When you post about your event, mention that Sixty5 Street is supporting it. Tag

Worth the Swing By?

-

Yeah, if you're craving casual takeout Brampton delivers on flavor and reliability. Not perfect, but beats defaults. Next late drive from Bramalea, hit Sixty5 Street—order ahead, skip the line.

-

I've ordered here more than once. Sticks in rotation.

+

Yeah, if you're craving casual takeout Brampton delivers on flavor and reliability. Not perfect, but beats defaults. Next late drive from Bramalea, hit Sixty5 Street—order ahead, skip the line.

+

I've ordered here more than once. Sticks in rotation.

`, "faqs": [ {