Skip to content

feat(Accordion): add sticky flag to make headers sticky in ScrollArea#2720

Merged
syeo66 merged 4 commits into
mainfrom
feat/add-sticky-header-accordion
May 12, 2026
Merged

feat(Accordion): add sticky flag to make headers sticky in ScrollArea#2720
syeo66 merged 4 commits into
mainfrom
feat/add-sticky-header-accordion

Conversation

@syeo66
Copy link
Copy Markdown
Contributor

@syeo66 syeo66 commented May 11, 2026

Summary

Adds an opt-in sticky prop on Accordion.Root. When enabled, each Accordion.Header pins to the top of the nearest scrolling ancestor (e.g. a ScrollArea) while its item is in view, then is pushed out by the next item's header — the classic sticky-section-header pattern.

<ScrollArea maxHeight={300}>
    <Accordion.Root sticky>
        <Accordion.Item value="…">
            <Accordion.Header></Accordion.Header>
            <Accordion.Content></Accordion.Content>
        </Accordion.Item>
        {/* … */}
    </Accordion.Root>
</ScrollArea>

Default is false, so existing usages are unchanged.

2026-05-11 14 15 10

@syeo66 syeo66 self-assigned this May 11, 2026
@syeo66 syeo66 requested a review from a team as a code owner May 11, 2026 12:21
@syeo66 syeo66 requested a review from SamuelAlev May 11, 2026 12:21
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 5e73c9b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@frontify/fondue-components Minor
@frontify/fondue Patch
@frontify/fondue-rte Patch

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

@netlify
Copy link
Copy Markdown

netlify Bot commented May 11, 2026

Deploy Preview for fondue-components ready!

Name Link
🔨 Latest commit 0ab26e6
🔍 Latest deploy log https://app.netlify.com/projects/fondue-components/deploys/6a01c9d1605bd400096798a9
😎 Deploy Preview https://deploy-preview-2720.components.fondue-components.frontify.com
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 11, 2026

Deploy Preview for fondue-components ready!

Name Link
🔨 Latest commit 5e73c9b
🔍 Latest deploy log https://app.netlify.com/projects/fondue-components/deploys/6a02f8a8b1a6a900089e9648
😎 Deploy Preview https://deploy-preview-2720.components.fondue-components.frontify.com
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@SamuelAlev SamuelAlev requested review from noahwaldner and removed request for SamuelAlev May 11, 2026 14:47
@noahwaldner
Copy link
Copy Markdown
Contributor

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.
https://github.com/user-attachments/assets/a8df4a49-b82a-4c33-bb31-f9c1aefe9546

@syeo66
Copy link
Copy Markdown
Contributor Author

syeo66 commented May 12, 2026

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.

@noahwaldner I think I got a reasonable solution now

Comment thread packages/components/src/components/Accordion/Accordion.tsx Outdated
Comment thread packages/components/src/components/Accordion/Accordion.tsx Outdated
Comment thread packages/components/src/components/Accordion/Accordion.tsx Outdated
Comment thread packages/components/src/components/Accordion/Accordion.tsx Outdated
Comment thread packages/components/src/components/Accordion/Accordion.tsx Outdated
Comment thread packages/components/src/components/Accordion/Accordion.tsx
@syeo66 syeo66 requested a review from noahwaldner May 12, 2026 09:53
@syeo66 syeo66 merged commit 976e5c8 into main May 12, 2026
9 checks passed
@syeo66 syeo66 deleted the feat/add-sticky-header-accordion branch May 12, 2026 10:58
@github-actions
Copy link
Copy Markdown
Contributor

Lead time: 22 hours, 38 minutes, 22 seconds (22.64 total hours) from first commit to close.
Review time: 22 hours, 36 minutes, 48 seconds (22.61 total hours) from ready for review to close.

  • First commit: 11.5.2026, 14:19:59.
  • Ready for review: 11.5.2026, 14:21:33.
  • Closed: 12.5.2026, 12:58:21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants