Skip to content

Commit

Permalink
feat(New dropdown): add new onOpenChange prop in Dropdown and Many2on…
Browse files Browse the repository at this point in the history
…eSuffix
  • Loading branch information
mguellsegarra committed Jan 19, 2024
1 parent 4ea60e0 commit 6a65194
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/ui/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const Dropdown: React.FC<DropdownProps> = memo(
trigger = ["click"],
placement,
maxHeight,
onOpenChange,
}: DropdownProps) => {
const [internalOpen, setInternalOpen] = useState(false);
const [emptyMenu, setEmptyMenu] = useState(false);
Expand Down Expand Up @@ -44,6 +45,7 @@ export const Dropdown: React.FC<DropdownProps> = memo(
trigger={trigger}
placement={placement}
onOpenChange={(open) => {
onOpenChange?.(open);
setInternalOpen(open);
}}
open={internalOpen}
Expand Down
1 change: 1 addition & 0 deletions src/components/ui/Dropdown/Dropdown.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type DropdownProps = BaseDropdownProps & {
disabled?: boolean;
children?: ReactNode;
placement?: Placement;
onOpenChange?: (open: boolean) => void;
};

export type DropdownButtonProps = Omit<DropdownProps, "children"> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { Many2OneSuffixProps } from "./Many2OneSuffix.types";
export const Many2OneSuffix = ({
onRetrieveData,
onItemClick,
onOpenChange,
}: Many2OneSuffixProps) => {
return (
<Dropdown
onRetrieveData={onRetrieveData}
onItemClick={onItemClick}
maxHeight={300}
trigger={["click"]}
onOpenChange={onOpenChange}
>
<RightCircleOutlined style={{ color: "rgba(0,0,0,.45)" }} />
</Dropdown>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { DropdownMenuGroup, DropdownMenuItem } from "@/components/ui";
export type Many2OneSuffixProps = {
onRetrieveData: () => Promise<DropdownMenuGroup[]>;
onItemClick?: (item: DropdownMenuItem) => void;
onOpenChange?: (open: boolean) => void;
};

0 comments on commit 6a65194

Please sign in to comment.