Vue Dialog jumps on click, body with margin-top #2388
Replies: 4 comments 3 replies
-
I'm stuck with the same issue. Have you solved this one? |
Beta Was this translation helpful? Give feedback.
-
I met the same issue and found the source code. https://github.com/tailwindlabs/headlessui/blob/0276231c31/packages/%40headlessui-react/src/hooks/document-overflow/handle-ios-locking.ts#L27-L28 Here we suppose if executing |
Beta Was this translation helpful? Give feedback.
-
Hi there ! After some investigation, I noticed that this behavior came from the fact that I added I found a workaround that works for me: it consists in forcing the Tested on Safari on iOS 16, Chrome on iOS 16 but not on Android. It doesn't seem to have any side effects on desktop. @thecrypticace, what do you think about this? I am wondering if this should not be added to the source code 🤔 Here is an exemple of how I implemented it in my app : <!-- MySuperDialog.vue -->
<template>
<Dialog :open="open" @close="open = false">
<DialogPanel>
<!-- ... -->
</DialogPanel>
</Dialog>
</template>
<script setup>
import { nextTick, ref, watch } from 'vue';
import { Dialog, DialogPanel } from '@headlessui/vue';
const open = ref(false);
// ...
watch(open, isOpen => {
if (isOpen) {
document.documentElement.style.scrollBehavior = 'auto';
} else {
// Wait for the modal to properly close
nextTick(() => {
document.documentElement.style.scrollBehavior = null; // Remove scrollBehavior style from root when modal is closed
});
}
});
</script> |
Beta Was this translation helpful? Give feedback.
-
Super late to this, but I noticed that removing the code below solved the issue of the scrolling to top. So in summary, having overflow styles on the body element caused the issue for me.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I have an issue with Dialog on iOS screens.
For some reason gets negative margin-top on Dialog open, making the page jump erratically. To make matters worse, the page doesn‘t return to the same position when Dialog is closed, resulting in terrible UX. Please see video.
Anyone experienced the same problem? 🙏
Screen.Recording.2023-03-21.at.15.37.27.mov
Beta Was this translation helpful? Give feedback.
All reactions