fix(navbar): allow height prop to accept number type and fix broken menu (#3601)

* fix(navbar): allow height prop to accept number type and fix broken menu

* fix(navbar): menu breaking when a numerical height value is provided. changeset
This commit is contained in:
Facundo Tenuta 2024-08-29 01:55:10 -03:00 committed by GitHub
parent 3c0a486cea
commit 048de6e9b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"@nextui-org/navbar": patch
---
Fix navbar menu breaking when a numerical height value is provided. The height value is now converted to pixels if it is a number.

View File

@ -50,7 +50,7 @@ const NavbarMenu = forwardRef<"ul", NavbarMenuProps>((props, ref) => {
data-open={dataAttr(isMenuOpen)}
style={{
// @ts-expect-error
"--navbar-height": height,
"--navbar-height": typeof height === "number" ? `${height}px` : height,
}}
{...otherProps}
>
@ -72,7 +72,7 @@ const NavbarMenu = forwardRef<"ul", NavbarMenuProps>((props, ref) => {
initial="exit"
style={{
// @ts-expect-error
"--navbar-height": height,
"--navbar-height": typeof height === "number" ? `${height}px` : height,
...style,
}}
variants={menuVariants}

View File

@ -198,7 +198,7 @@ export function useNavbar(originalProps: UseNavbarProps) {
ref: domRef,
className: slots.base({class: clsx(baseStyles, props?.className)}),
style: {
"--navbar-height": height,
"--navbar-height": typeof height === "number" ? `${height}px` : height,
...otherProps?.style,
...props?.style,
},