Skip to content
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

[Bug]: Modal jumps horizontally when closing (on Windows) #421

Closed
pimski opened this issue Apr 21, 2021 · 4 comments
Closed

[Bug]: Modal jumps horizontally when closing (on Windows) #421

pimski opened this issue Apr 21, 2021 · 4 comments

Comments

@pimski
Copy link

pimski commented Apr 21, 2021

What package within Headless UI are you using?

@headlessui/vue

What version of that package are you using?

1.0.0

What browser are you using?

Chrome on Windows 10

Reproduction repository

https://www.youtube.com/watch?v=aYMffRukfCA

Describe your issue

If you have a modal component that is centered horizontally and the page has a vertical scrollbar the modal jumps to the left when you close it.

Headlessui adds padding-right to compensate for "hiding" the scrollbar when a modal opens. Which is good, since it prevents annoying page jumps. However, when you close the modal the padding is removed while the hiding animation is not finished yet. This causes the modal to jump to the left.

My guess is, the padding should be removed after the animation.

Ps. I used a dialog from tailwindui to test the headlessui components.

@lkbr
Copy link

lkbr commented Apr 21, 2021

There's a video of the jump in this comment: #365 (reply in thread)

@Andrey-Bazhanov
Copy link

It can be fixed like this: https://codesandbox.io/s/headlessui-dialog-scroll-jumping-fix-f6uxv?file=/pages/index.js

@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

This should be fixed in the latest version! However, make sure to cleanup some of Dialog code. For example, you don't require an open and static prop anymore (more info: https://headlessui.dev/react/dialog#transitions).

@pimski
Copy link
Author

pimski commented May 17, 2021

Thanks Robin! Can confirm it works now (after updating the modal code to the latest example on TailwindUI)

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

No branches or pull requests

4 participants