Replies: 1 comment 1 reply
-
I ran into something similar, and tried a few different workarounds, like refs + attribute listeners. All felt a bit hacky. This ended up being a pretty reasonable solution imo: <Menu as="div" className="relative md:hidden">
{({ open }) => {
document.body.classList.toggle('overflow-y-hidden', open);
return (
<>
{open && <div className="fixed inset-0 bg-black/25" />}
<Menu.Button className="h-10 w-10 flex justify-center items-center">
<Bars3Icon className="h-6 w-6 text-slate-900" />
</Menu.Button>
<Menu.Items className="absolute right-0 mt-3 min-w-[160px] origin-top-right rounded-md bg-white">
<div className="px-3 py-1">
{links.map(({ label, href }) => (
<Menu.Item key={href}>
<Link
href={href}
className="..."
>
{label}
</Link>
</Menu.Item>
))}
</div>
</Menu.Items>
</>
);
}}
</Menu> Key notes:
From what I can see, this does fire when |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! We were facing a situation where we don't want that the user can scroll the page when the Menu or Popover is open (we use both in some pages) we love the way that Material UI made it:
The pass a
keepAlive
prop toMenu
component and depending on that prop they can make use of the overflow hidden in thebody
. This is useful when for example we have a dropdown inside a menu that hides from the viewport if you scroll down, but if you scroll up the menu, appear (sticky) so it could be great to have that functionality inside Headless UIThis is the type of behaviour that we want to avoid
ff500f1ca83a27dbc88edb2f20f3b553.mp4
Beta Was this translation helpful? Give feedback.
All reactions