-
Notifications
You must be signed in to change notification settings - Fork 823
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
[1.x] Make livewire modal scrollable #378
Conversation
* inset-0, overflow-y-auto - scroll the modal * py-6 - add bottom padding for the modal parent
Replace parent `padding-bottom` to child `margin-bottom` as described here https://stackoverflow.com/a/38177668/3071884
Nothing needs to be changed on the Inertia version? |
@taylorotwell I have commited the same changes for Inertia. I tested it locally copying UPD. Inertia already had |
The following commit eb0ff84 has a little annoyance. When the modal shows, the scrollbar disappears in the browser causing a slight shift. Might be distracting to some. |
The problem
When using
x-jet-dialog-modal
on mobile and if the dialog has a lot of content you can't scroll to reach the content that doesn't fit in the screen.Also the body of the document scrolls when modal is open.
The solution
This PR makes Modal scrollable when it is taller than the screen.
It is based on the #305 (it just disabled the body scrolling when modal is open) but also makes the modal itself scrollable.
It contains a hack for Firefox that can't work with
padding bottom
andoverflow: auto
as described on SO.P.S. During the testing I have noticed that there's
sm:items-top
class that doesn't even exist. It should besm:items-start
.Thinking about it - these classes just make the modal centered horizontally on larger screens
sm:flex sm:items-start sm:justify-center
.We can achieve the same with just
sm:mx-auto
on the child element. And it will also help with the bottom space mentioned above. When we useflex
the hack doesn't work.How to test the PR
I tested this PR locally on Windows in fresh Chrome and Firefox.
You might want to recompile your assets to make sure that the classes I use here were not purged.
And you might want to hard refresh browser page Ctrl+F5 to prevent it using cached version of the
app.css
.To test this PR I created a fresh Laravel project with Livewire stack.
Set up your local database
Create a Livewire component
Edit the component and the view
Prepare the welcome page to use the modal
Don't forget to add a repository to the
composer.json
as described hereRun the website
php artisan server
and open http://127.0.0.1:8000/ in your browser.Make the browser window smaller and this is what you should see
Click the button and try to scroll the modal.
Notice that the body of the document doesn't scroll when modal is open.
Hope you'll like it.