-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ui): modal scrolling behavior on mobile #1620
fix(ui): modal scrolling behavior on mobile #1620
Conversation
Moves the scrollable section one level down, placing it directly inside <Drawer.Content /> as its child. This change ensures that when scrolling is active, no :after pseudo-elements are unintentionally visible. Improves visual consistency and resolves minor aesthetic bugs related to scrollbars and overflow.
@unrenamed is attempting to deploy a commit to the Dub Team on Vercel. A member of the Team first needs to authorize it. |
@steven-tey Just merged with the latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@unrenamed previously our AddEditDomainModal
and AddEditTokenModal
were scrollable on desktop (with a short window height), but now they aren't - can we restore this?
Ideally all of our modals would just be scrollable by default, but I'm not sure how big of a lift that would be.
@TWilson023 My bad, I missed that the Adding |
@TWilson023 Feel free to check again. I pushed the fix. As for, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@unrenamed this is looking better now, thank you!
I did notice one more issue that I'm not seeing on main
: on Chrome iOS, I can't seem to open the AddEditDomainModal
or other updated modals. Any chance you're able to reproduce this on another mobile device?
modal.mp4
@TWilson023 The issue might be due to Chrome on iOS using the WebKit engine, as I can reproduce it in Safari as well. Applying |
@TWilson023 The fix appears to work on my end. Can you confirm if it’s resolved for you as well? |
@TWilson023 @steven-tey Here are a few questions for further refactoring:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's still some mobile glitchiness with the software keyboard for some drawers but I don't think this PR is causing any additional issues now. We'll probably want to do a separate Vaul upgrade PR soon and see if we can work out some of the remaining issues.
re further refactoring:
- Having a default
max-h-[95dvh]
andoverflow-y-auto
seems like a good idea to me - not sure if it'd be that simple or cause any new problems. - Separating the drawer & modal classNames seems like something we'll have to do, though if we don't need them separated for most use cases, we could do something like a
className?: string | (isDrawer: boolean) => string
prop to keep things simple and avoid updating a bunch of existing uses.
Up to @steven-tey for where any of this additional work fits in!
Awarding unrenamed: 750 points 🕹️ Well done! Check out your new contribution on oss.gg/unrenamed |
Just merged! Thanks so much for your work on this again @unrenamed 🙏 |
/award 750 |
Awarding unrenamed: 750 points 🕹️ Well done! Check out your new contribution on oss.gg/unrenamed |
What does this PR do?
Moves the scrollable section one level down, placing it directly inside
<Drawer.Content />
as its child. This change ensures that when scrolling is active, no:after
pseudo-elements are unintentionally visible. Improves visual consistency and resolves minor aesthetic bugs related to scrollbars and overflow.Fixes: #1609
TL;DR
Although @aritradevelops were right in their #1612 PR about the use of Vaul's drawer that is shipped with some default CSS, the actual root cause was quite unexpected.
Issue Diagnosis
Who is the bad guy?
This was the first question to answer: how is it possible that the scrollable drawer from the official Vaul website does NOT have such an issue. Check this yourself: https://vaul.emilkowal.ski/default#scrollable. It also has that same
:after
pseudo-element withheight: 200%
property.And if you take a closer look, you may notice that the
<Drawer.Content />
isn’t the one getting scrolled when its content expands. Nope, it’s the first child<div>
block that’s hogging all the action!But why does it break the UI?
It's easy.
overflow: auto
enables scrolling for the drawer parent container (the<Drawer.Content />
component). The default CSS shipped with the package contains an:after
pseudo-element, which is a child of the parent container. Enabling scrolling for the parent container made all children — including the:after
— visible. Removingoverflow: auto
fixes the problem, but introduces another: the Create button gets cut off at the bottom.Ugh, what now?
Do you see that
max-h-[95h]
class on the parent element? It does a few things:Key point: if overflow is allowed. And guess what? It’s not! We removed it from the parent container, remember? Did we add one to any of its children? Nope!
So, what's the fix?
Adding
overflow
oroverflow-y
to the children of the<Drawer.Content />
allows them to handle scrolling when the inner content exceeds the specified height. Check the code for a clearer picture.Why this is anyway better than the fix suggested in #1612 PR?
I see two big red flags with overriding CSS globally:
Result
This is how the fixed modal looks on mobile:
Screen.Recording.2024-10-23.at.18.08.41.mov
And this is how it looks in full screen:
Screen.Recording.2024-10-23.at.18.11.07.mov