Skip to content

Commit 6a2e6b7

Browse files
fix: fixed forwardRef warning on customSelect
1 parent ab68b67 commit 6a2e6b7

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

client/packages/lowcoder-design/src/components/customSelect.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,29 @@ const SelectWrapper = styled.div<{ border?: boolean }>`
7171
}
7272
`;
7373

74-
export type CustomSelectProps = {
74+
export interface CustomSelectProps extends AntdSelectProps {
7575
children?: JSX.Element | React.ReactNode;
76-
innerRef?: React.Ref<HTMLDivElement> | undefined;
7776
border?: boolean;
7877
};
7978

80-
function CustomSelect(props: CustomSelectProps & AntdSelectProps) {
79+
interface CustomSelectInterface extends React.ForwardRefExoticComponent<
80+
CustomSelectProps & React.RefAttributes<HTMLDivElement>
81+
> {
82+
Option: any;
83+
}
84+
const CustomSelect = React.forwardRef<HTMLDivElement, CustomSelectProps>((
85+
props,
86+
ref,
87+
) => {
8188
const {
8289
children,
83-
innerRef,
8490
className,
8591
border,
8692
popupClassName = "custom-ant-select-dropdown",
8793
...restProps
8894
} = props;
8995
return (
90-
<SelectWrapper className={className} ref={innerRef} border={border}>
96+
<SelectWrapper className={className} ref={ref} border={border}>
9197
<AntdSelect
9298
popupClassName={popupClassName}
9399
popupMatchSelectWidth={false}
@@ -96,9 +102,10 @@ function CustomSelect(props: CustomSelectProps & AntdSelectProps) {
96102
>
97103
{children}
98104
</AntdSelect>
105+
<div></div>
99106
</SelectWrapper>
100107
);
101-
}
108+
}) as CustomSelectInterface;
102109

103110
CustomSelect.Option = AntdSelect.Option;
104111
export { CustomSelect };

client/packages/lowcoder/src/components/PermissionDialog/Permission.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ const PermissionSelector = (props: {
328328
<PermissionSelectWrapper>
329329
<AddPermissionsSelect
330330
open
331-
innerRef={selectRef}
331+
ref={selectRef}
332332
placeholder={trans("home.addPermissionPlaceholder")}
333333
mode="multiple"
334334
getPopupContainer={() => document.getElementById("add-app-user-permission-dropdown")!}

0 commit comments

Comments
 (0)