From 6a6519413b962c6da8d7bcaa2e56523494146f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20G=C3=BCell=20Segarra?= Date: Fri, 19 Jan 2024 11:23:44 +0100 Subject: [PATCH] feat(New dropdown): add new onOpenChange prop in Dropdown and Many2oneSuffix --- src/components/ui/Dropdown/Dropdown.tsx | 2 ++ src/components/ui/Dropdown/Dropdown.types.ts | 1 + .../widgets/Many2One/Many2OneSuffix/Many2OneSuffix.tsx | 2 ++ .../widgets/Many2One/Many2OneSuffix/Many2OneSuffix.types.tsx | 1 + 4 files changed, 6 insertions(+) diff --git a/src/components/ui/Dropdown/Dropdown.tsx b/src/components/ui/Dropdown/Dropdown.tsx index c272135..d0b75e1 100644 --- a/src/components/ui/Dropdown/Dropdown.tsx +++ b/src/components/ui/Dropdown/Dropdown.tsx @@ -14,6 +14,7 @@ export const Dropdown: React.FC = memo( trigger = ["click"], placement, maxHeight, + onOpenChange, }: DropdownProps) => { const [internalOpen, setInternalOpen] = useState(false); const [emptyMenu, setEmptyMenu] = useState(false); @@ -44,6 +45,7 @@ export const Dropdown: React.FC = memo( trigger={trigger} placement={placement} onOpenChange={(open) => { + onOpenChange?.(open); setInternalOpen(open); }} open={internalOpen} diff --git a/src/components/ui/Dropdown/Dropdown.types.ts b/src/components/ui/Dropdown/Dropdown.types.ts index bb4cdd6..04a00d5 100644 --- a/src/components/ui/Dropdown/Dropdown.types.ts +++ b/src/components/ui/Dropdown/Dropdown.types.ts @@ -24,6 +24,7 @@ export type DropdownProps = BaseDropdownProps & { disabled?: boolean; children?: ReactNode; placement?: Placement; + onOpenChange?: (open: boolean) => void; }; export type DropdownButtonProps = Omit & { diff --git a/src/components/widgets/Many2One/Many2OneSuffix/Many2OneSuffix.tsx b/src/components/widgets/Many2One/Many2OneSuffix/Many2OneSuffix.tsx index 264bfdd..1e200cc 100644 --- a/src/components/widgets/Many2One/Many2OneSuffix/Many2OneSuffix.tsx +++ b/src/components/widgets/Many2One/Many2OneSuffix/Many2OneSuffix.tsx @@ -5,6 +5,7 @@ import { Many2OneSuffixProps } from "./Many2OneSuffix.types"; export const Many2OneSuffix = ({ onRetrieveData, onItemClick, + onOpenChange, }: Many2OneSuffixProps) => { return ( diff --git a/src/components/widgets/Many2One/Many2OneSuffix/Many2OneSuffix.types.tsx b/src/components/widgets/Many2One/Many2OneSuffix/Many2OneSuffix.types.tsx index 1ec34b8..a08f712 100644 --- a/src/components/widgets/Many2One/Many2OneSuffix/Many2OneSuffix.types.tsx +++ b/src/components/widgets/Many2One/Many2OneSuffix/Many2OneSuffix.types.tsx @@ -3,4 +3,5 @@ import { DropdownMenuGroup, DropdownMenuItem } from "@/components/ui"; export type Many2OneSuffixProps = { onRetrieveData: () => Promise; onItemClick?: (item: DropdownMenuItem) => void; + onOpenChange?: (open: boolean) => void; };