Skip to content

Conversation

braden-w
Copy link
Contributor

@braden-w braden-w commented Jul 22, 2025

This change enables proper vertical scrolling for drawer components when content exceeds the drawer height, inspired by @huntabyte 's implementation in the vaul-svelte docs. Previously, drawers with long content could overflow without proper scrolling behavior, making it difficult for users to access all content and resulting in poor mobile UX.

To accomplish this, I wrapped the {@render children?.()} in a <div class="flex-1 overflow-y-auto"> container. The flex-1 class ensures the content takes up remaining space after the drag handle at the top, while overflow-y-auto enables vertical scrolling.

Add scrollable wrapper div around drawer children that:
- Uses flex-1 to take remaining space after the fixed drag handle
- Uses overflow-y-auto to enable vertical scrolling when content exceeds drawer height
- Maintains the drag handle as fixed at the top while content scrolls independently

This improves UX for drawers with long content by enabling proper vertical
scrolling behavior without layout issues.
Copy link

changeset-bot bot commented Jul 22, 2025

⚠️ No Changeset found

Latest commit: 403a467

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Jul 22, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
shadcn-svelte ✅ Ready (View Log) Visit Preview 403a467

@braden-w braden-w changed the title feat(drawer): wrap drawer content in scrollable container feat(drawer): enable drawer content scroll on overflow Jul 22, 2025
@huntabyte
Copy link
Owner

Does applying overflow-y-auto to the content not work as expected when you have overflowing content?

@braden-w
Copy link
Contributor Author

braden-w commented Jul 24, 2025

@huntabyte Unfortunately not, I tried also tried the overflow-auto code onto the Drawer.Content component, but it doesn't scroll properly, seems to overflow with a ton of random whitespace. You can look into the StackBlitz here and try moving the overflow-auto class from the div into the Drawer.Content.

Putting overflow-auto on the inner div:

CleanShot 2025-07-24 at 16 48 34@2x

Putting it on the Drawer.Content. Notice the extra whitespace and how it's suddenly much taller.

CleanShot 2025-07-24 at 16 49 04@2x CleanShot 2025-07-24 at 16 49 07@2x

Not sure if this is what's happening, but it seems like it's simultaneously adding a scroll bar because there's not enough space, but it also is taller, giving it more space than necessary compared to the previously computed amount of scrollthat would be needed. And so the scroll bar now has a bunch of extra white space to scroll into.

It's unclear to me if the change I propose is the best course of action, though.

  1. Should we always wrap with the div and overflow-y-auto?
  2. At the same time, maybe a code example in the docs would suffice so they know how to handle overflow?
  3. Maybe this is something we should fix in vaul-svelte?

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