mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(navbar): remove NavbarMenu when closed (#4506)
* fix(navbar): remove NavbarMenu when closed * chore(changeset): fixed NavbarMenu console prop error
This commit is contained in:
parent
f7e5d205b1
commit
61ad0205c5
5
.changeset/nice-beds-battle.md
Normal file
5
.changeset/nice-beds-battle.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@nextui-org/navbar": patch
|
||||
---
|
||||
|
||||
fixed NavbarMenu React.Fragment prop error when animation is disabled (#4501)
|
||||
@ -32,25 +32,28 @@ const NavbarMenu = forwardRef<"ul", NavbarMenuProps>((props, ref) => {
|
||||
|
||||
const styles = clsx(classNames?.menu, className);
|
||||
|
||||
// only apply overlay when menu is open
|
||||
const OverlayComponent = isMenuOpen ? Overlay : React.Fragment;
|
||||
if (disableAnimation) {
|
||||
if (!isMenuOpen) return null;
|
||||
|
||||
const contents = disableAnimation ? (
|
||||
<OverlayComponent portalContainer={portalContainer}>
|
||||
<ul
|
||||
ref={domRef}
|
||||
className={slots.menu?.({class: styles})}
|
||||
data-open={dataAttr(isMenuOpen)}
|
||||
style={{
|
||||
// @ts-expect-error
|
||||
"--navbar-height": typeof height === "number" ? `${height}px` : height,
|
||||
}}
|
||||
{...otherProps}
|
||||
>
|
||||
{children}
|
||||
</ul>
|
||||
</OverlayComponent>
|
||||
) : (
|
||||
return (
|
||||
<Overlay portalContainer={portalContainer}>
|
||||
<ul
|
||||
ref={domRef}
|
||||
className={slots.menu?.({class: styles})}
|
||||
data-open={dataAttr(isMenuOpen)}
|
||||
style={{
|
||||
// @ts-expect-error
|
||||
"--navbar-height": typeof height === "number" ? `${height}px` : height,
|
||||
}}
|
||||
{...otherProps}
|
||||
>
|
||||
{children}
|
||||
</ul>
|
||||
</Overlay>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<AnimatePresence mode="wait">
|
||||
{isMenuOpen ? (
|
||||
<Overlay portalContainer={portalContainer}>
|
||||
@ -78,8 +81,6 @@ const NavbarMenu = forwardRef<"ul", NavbarMenuProps>((props, ref) => {
|
||||
) : null}
|
||||
</AnimatePresence>
|
||||
);
|
||||
|
||||
return contents;
|
||||
});
|
||||
|
||||
NavbarMenu.displayName = "HeroUI.NavbarMenu";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user