I recently encountered an issue with nested accordions. In my project, I have implemented accordions within other accordions, but ran into a problem when the inner accordion expanded and affected the size of the parent accordion. Here's what's happening:
In the first component, /components/loved_one.js, which is rendered by /pages/profile.js, I use a toggleAccordion function that sets the scrollheight of the inner accordion container based on its content. This works well because initially none of the elements within are expanded, allowing for accurate height calculation.
However, in another component, /components/event.js, the same mechanism is applied for the inner accordion. When it expands, it causes the parent accordion above to become too small, resulting in layout issues.
The solution was to collapse and expand the parent accordion to trigger a re-adjustment of its height based on the expanded inner elements. However, I'm looking for a more automatic way to handle this without manual intervention.
If anyone has any suggestions or solutions on how I can sync the heights of both the inner and parent accordions dynamically, I would greatly appreciate it.
Below is the code snippets related to these components:
/pages/profile.js
Your profile page code snippet...
/components/loved_one.js
Your loved_one component code snippet...
/components/events.js
Your events component code snippet...