[Bug Fix] Accordion clips content that grows after opening
Merged
PI
4mo ago+33+33+01234567890123456789-19-19-01234567890123456789
Related issue
No existing issue — happy to open one if you'd prefer to track it separately.
Description
revealContent() measures scrollHeight at open time and animates the panel to that fixed pixel height. The inline height then stays frozen, so any content that grows after the panel is already open — a lazy-loaded iframe/image, an async-rendered row, a nested control that expands — is clipped by the panel's fixed height + overflow.
This fix makes the panel resilient to content that changes after opening:
revealContent()— once the open animation finishes (and the item is still open), release the fixed height back toheight: auto, so the panel tracks its content instead of freezing at the height measured on open.hideContent()— collapse from the element's current rendered height (getBoundingClientRect().height) via an explicit[from, "0px"]keyframe. Motion can't interpolate fromauto, so an explicit start is required now that the open state isauto. Using the current height (notscrollHeight) also avoids a jump-to-full-height on fast open→close toggles.- A
.catch(() => {})guards the newfinishedpromise onrevealContent(closing mid-open-animation rejects it).
The open/close animation is visually unchanged — only the resting open state goes from a fixed pixel height to auto. The existing hidden-attribute and data-state behavior is preserved.