Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ForwardRefs warning on CustomSelect #334

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions client/packages/lowcoder-design/src/components/customSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,29 @@ const SelectWrapper = styled.div<{ border?: boolean }>`
}
`;

export type CustomSelectProps = {
export interface CustomSelectProps extends AntdSelectProps {
children?: JSX.Element | React.ReactNode;
innerRef?: React.Ref<HTMLDivElement> | undefined;
border?: boolean;
};

function CustomSelect(props: CustomSelectProps & AntdSelectProps) {
interface CustomSelectInterface extends React.ForwardRefExoticComponent<
CustomSelectProps & React.RefAttributes<HTMLDivElement>
> {
Option: any;
}
const CustomSelect = React.forwardRef<HTMLDivElement, CustomSelectProps>((
props,
ref,
) => {
const {
children,
innerRef,
className,
border,
popupClassName = "custom-ant-select-dropdown",
...restProps
} = props;
return (
<SelectWrapper className={className} ref={innerRef} border={border}>
<SelectWrapper className={className} ref={ref} border={border}>
<AntdSelect
popupClassName={popupClassName}
popupMatchSelectWidth={false}
Expand All @@ -96,9 +102,10 @@ function CustomSelect(props: CustomSelectProps & AntdSelectProps) {
>
{children}
</AntdSelect>
<div></div>
</SelectWrapper>
);
}
}) as CustomSelectInterface;

CustomSelect.Option = AntdSelect.Option;
export { CustomSelect };
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const PermissionSelector = (props: {
<PermissionSelectWrapper>
<AddPermissionsSelect
open
innerRef={selectRef}
ref={selectRef}
placeholder={trans("home.addPermissionPlaceholder")}
mode="multiple"
getPopupContainer={() => document.getElementById("add-app-user-permission-dropdown")!}
Expand Down
Loading