mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 01:21:48 +03:00
fix: fix button bad children error (#1564)
Issue: https://github.com/StanGirard/quivr/issues/1498
This commit is contained in:
parent
867904f19d
commit
5c732f1253
@ -18,17 +18,15 @@ export const PopoverMenuMobile = ({
|
||||
<Popover.Root>
|
||||
<div>
|
||||
<Popover.Anchor />
|
||||
<Popover.Trigger>
|
||||
<button
|
||||
title="menu"
|
||||
type="button"
|
||||
className={cn(
|
||||
"bg-[#D9D9D9] bg-opacity-30 rounded-full px-4 py-1",
|
||||
color === "white" ? "text-white" : "text-black"
|
||||
)}
|
||||
>
|
||||
<LuMenu size={32} />
|
||||
</button>
|
||||
<Popover.Trigger
|
||||
title="menu"
|
||||
type="button"
|
||||
className={cn(
|
||||
"bg-[#D9D9D9] bg-opacity-30 rounded-full px-4 py-1",
|
||||
color === "white" ? "text-white" : "text-black"
|
||||
)}
|
||||
>
|
||||
<LuMenu size={32} />
|
||||
</Popover.Trigger>
|
||||
</div>
|
||||
<Popover.Content
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
TooltipTrigger,
|
||||
} from "@radix-ui/react-tooltip";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { ButtonHTMLAttributes, LegacyRef, forwardRef } from "react";
|
||||
import { ButtonHTMLAttributes, Ref, RefAttributes, forwardRef } from "react";
|
||||
import { FaSpinner } from "react-icons/fa";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
@ -56,22 +56,25 @@ const Button = forwardRef(
|
||||
}: ButtonProps,
|
||||
forwardedRef
|
||||
): JSX.Element => {
|
||||
const buttonElement = (
|
||||
<button
|
||||
className={cn(ButtonVariants({ variant, brightness, className }))}
|
||||
disabled={isLoading}
|
||||
{...props}
|
||||
ref={forwardedRef as LegacyRef<HTMLButtonElement>}
|
||||
>
|
||||
const buttonProps: ButtonProps & RefAttributes<HTMLButtonElement> = {
|
||||
className: cn(ButtonVariants({ variant, brightness, className })),
|
||||
disabled: isLoading,
|
||||
...props,
|
||||
ref: forwardedRef as Ref<HTMLButtonElement> | undefined,
|
||||
};
|
||||
|
||||
const buttonChildren = (
|
||||
<>
|
||||
{children} {isLoading && <FaSpinner className="animate-spin" />}
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
const buttonElement = <button {...buttonProps}>buttonChildren</button>;
|
||||
|
||||
if (tooltip !== undefined) {
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger>{buttonElement}</TooltipTrigger>
|
||||
<TooltipTrigger {...buttonProps}>{buttonChildren}</TooltipTrigger>
|
||||
<TooltipContent className="bg-gray-100 rounded-md p-1">
|
||||
{tooltip}
|
||||
</TooltipContent>
|
||||
@ -80,9 +83,8 @@ const Button = forwardRef(
|
||||
);
|
||||
}
|
||||
|
||||
return buttonElement;
|
||||
return <button {...buttonProps}>{buttonChildren}</button>;
|
||||
}
|
||||
);
|
||||
|
||||
Button.displayName = "Button";
|
||||
export default Button;
|
||||
|
Loading…
Reference in New Issue
Block a user