Can you disable html overflow="hidden" when Dialog is open? #2181
Replies: 19 comments 12 replies
-
same problem, making this optional would be great. Or maybe change this behaviour to overflow: clip, which is relatively new though: https://caniuse.com/?search=overflow%3A%20clip |
Beta Was this translation helpful? Give feedback.
-
I'm also having a similar issue here: #2305 Did you figure out a work around for this problem? |
Beta Was this translation helpful? Give feedback.
-
Also I can confirm the issue is the overflow: hidden. So far I can't find a good way to override this while maintaining the same behaviour 🤷♂️ |
Beta Was this translation helpful? Give feedback.
-
Anyone figure out a fix for this? Hitting the same thing with a sticky header. RPReplay_Final1681919010.MP4 |
Beta Was this translation helpful? Give feedback.
-
Having this exact issue with my project: https://github.com/13vaults/13vaults.com/blob/218f092d851c2e5f2f23114c7153c62438db7dbe/components/mega-nav.tsx (https://www.13vaults.com). I only just now realized it was a bug with the dialog component + a sticky element. Losing my hair for weeks over this 😅 Would love to see a way to address this--it might just be a thing only a webkit update can fix though 😿 |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
Same issue here... Please provide a solution. |
Beta Was this translation helpful? Give feedback.
-
Same issue :( |
Beta Was this translation helpful? Give feedback.
-
Same issue with the current version 1.7.15. |
Beta Was this translation helpful? Give feedback.
-
I solve this issue forcing to use always the css property that i want, like so:
so the inline overflow hidden style is ignored. |
Beta Was this translation helpful? Give feedback.
-
I got around this with a bit of a hack: useEffect(() => {
let timer: number;
if (open) {
timer = setTimeout(() => {
const html = document.documentElement;
html.style.overflow = 'auto'; // revert to default overflow
});
}
return () => {
clearTimeout(timer);
};
}, [open]); Wrapping it in a setTimeout puts it in a different execution cycle (I guess). You don't even need to introduce an actual delay. |
Beta Was this translation helpful? Give feedback.
-
I have a sticky sidebar, and when a Headless UI modal opens, the sidebar will not stay sticky. html {
overflow: visible !important;
} or using tailwind <html className="!overflow-visible">...<html> |
Beta Was this translation helpful? Give feedback.
-
html:has(dialog[open]) { |
Beta Was this translation helpful? Give feedback.
-
Fix for this issue, which you can use in
|
Beta Was this translation helpful? Give feedback.
-
I fix this issue, you must add styled in custom.css . body {
overflow: unset !important;
} |
Beta Was this translation helpful? Give feedback.
-
Can someone explain the reasoning behind Headless UI adding padding and overflow by default? |
Beta Was this translation helpful? Give feedback.
-
I think, apply |
Beta Was this translation helpful? Give feedback.
-
I don't have this issue with Dialog, but I've had this issue with Popover and Listbox. Writing this to help people who has this problem with other types of components as well. These components has a Example
As stated, it's not a perfect solution.. have anyone found anything better yet? |
Beta Was this translation helpful? Give feedback.
-
use
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Opening a dialog sets the HTML element inline style as "overflow: hidden"
I am assuming this is to prevent scrolling, however:
This is causing elements with position: sticky to disappear.
headlessui-overflow-issue.mov
Beta Was this translation helpful? Give feedback.
All reactions