-
Notifications
You must be signed in to change notification settings - Fork 1.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
[bug] weird(cannot) scroll after two dialog intersect showing #1698
Comments
This is happening for me too in vue with headless v 1.6.7. When two modals are open and both are closed one after the other the overflow: hidden remains on the outter html tag |
Here's a reproduction link: |
I'm using this as a workaround // prevent scroll bug
// https://github.com/tailwindlabs/headlessui/issues/1698
const HTMLDOM = document.querySelector('html')
if (HTMLDOM) {
// https://stackoverflow.com/a/67384208/6236633
// HTMLDOM.style = ''
HTMLDOM.setAttribute('style', '')
} example: //
// utils.ts
//
export const preventScrollBug = () => {
// prevent scroll bug
// https://github.com/tailwindlabs/headlessui/issues/1698
const HTMLDOM = document.querySelector('html')
// console.log('html dom', HTMLDOM)
if (HTMLDOM) {
// https://stackoverflow.com/a/67384208/6236633
// HTMLDOM.style = ''
HTMLDOM.setAttribute('style', '')
}
}
//
// my custom loading mask
//
/* ... */
<Transition appear show={showMask}
afterLeave={() => {
setTimeout(() => {
Utils.preventScrollBug()
})
}}
/* ... */ This will make sure the |
@timmaier I can't reproduce this with your stackblitz (also the url in the markdown is not filled in 😄) Perhaps I'm doing something wrong here tho? Screen.Recording.2022-07-28.at.09.21.04.mov |
Hey @thecrypticace yeah weird that's the exact use case I tested here is a screen recording of the behaviour in the stackblitz: https://stackblitz.com/edit/vitejs-vite-bbesl5?file=README.md I'm using chrome: Version 102.0.5005.115 (Official Build) (arm64) |
Okay I think it seems to only happen when I hit ESC key twice to close both modals? Here's a replication stackblitz with a closeBoth handler: https://stackblitz.com/edit/vitejs-vite-7sjhss?file=src/App.vue |
Ah yep that reproduces the issue! And the ESC key closes the wrong modal first… 🤦 . Awesome thanks for the reproduction. Will take a look! |
Okay, I talked with @RobinMalfait some and we actually don't support multiple open sibling dialogs. It is definitely something we want to support but there will likely be more we have to change to properly support that. In the short term you might be able to work around the issue by nesting the dialogs/modals inside one another as children. This allows us to properly restore state. This is also why the ESC closes the first modal first and not the second one. I'm closing this for now (sorry!) but will keep it on the mind for when we do eventually find a way to properly support multiple open dialogs that are siblings. Here's a comment from an earlier issue with some examples with nested versus sibling dialogs: #426 (comment) |
headlessui/packages/@headlessui-react/src/components/dialog/dialog.tsx
Line 254 in 5af3bd4
html style
hasoverflow:hidden
html style
is emptyhtml style
is emptyhtml style
hasoverflow:hidden
The text was updated successfully, but these errors were encountered: