feat(Accordion): add sticky flag to make headers sticky in ScrollArea#2720
Conversation
🦋 Changeset detectedLatest commit: 5e73c9b The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for fondue-components ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for fondue-components ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
We should probably add some functionality for scroll restoration. Because of the changing vertical size of each item, the active item vanishes when collapsing. In long sections (like theme settings) this would seem confusing to the user. Measuring if the current scroll position is bigger than the Accordion.Headers distance from the top of the accordion would tell us if the item is in "sticky state". We could then manually set the scroll position so it's still top aligned after closing. The difficulty with this would be to get the current scroll position if the scrollarea is added by the consumer Video to demonstrate the issue. |
@noahwaldner I think I got a reasonable solution now |
|
Lead time: 22 hours, 38 minutes, 22 seconds (22.64 total hours) from first commit to close.
|
Summary
Adds an opt-in
stickyprop onAccordion.Root. When enabled, eachAccordion.Headerpins to the top of the nearest scrolling ancestor (e.g. aScrollArea) while its item is in view, then is pushed out by the next item's header — the classic sticky-section-header pattern.Default is
false, so existing usages are unchanged.