Skip to content

Commit

Permalink
fix(select): 🩹 update fork ref declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed Jul 14, 2022
1 parent 31f7e71 commit 3b41c70
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/select/SelectProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ export const useSelectProps = ({
const selectInlineStyles = React.useRef<Record<string, any>>({});
let prefixRef = React.useRef<HTMLElement>(null);
let suffixRef = React.useRef<HTMLElement>(null);
prefixRef = useForkRef(
prefixRef,
componentProps?.prefixProps?.ref,
) as unknown as React.RefObject<HTMLElement>;
suffixRef = useForkRef(
suffixRef,
componentProps?.suffixProps?.ref,
) as unknown as React.RefObject<HTMLElement>;

useSafeLayoutEffect(() => {
let key = "";
Expand Down Expand Up @@ -124,26 +116,34 @@ export const useSelectProps = ({
[componentProps.baseProps, disabled, finalChildren, restProps, uiProps],
);

const _prefixRef = useForkRef(
prefixRef,
componentProps?.prefixProps?.ref,
) as unknown as React.RefObject<HTMLElement>;
const prefixProps: SelectPrefixProps = React.useMemo(
() => ({
...uiProps,
disabled,
...componentProps.prefixProps,
ref: prefixRef,
ref: _prefixRef,
children: withIconA11y(uiProps.prefix, uiProps),
}),
[componentProps.prefixProps, disabled, uiProps],
[_prefixRef, componentProps.prefixProps, disabled, uiProps],
);

const _suffixRef = useForkRef(
suffixRef,
componentProps?.suffixProps?.ref,
) as unknown as React.RefObject<HTMLElement>;
const suffixProps: SelectSuffixProps = React.useMemo(
() => ({
...uiProps,
disabled,
...componentProps.suffixProps,
ref: suffixRef,
ref: _suffixRef,
children: uiProps.suffix,
}),
[componentProps.suffixProps, disabled, uiProps],
[_suffixRef, componentProps.suffixProps, disabled, uiProps],
);
return {
uiProps,
Expand Down

0 comments on commit 3b41c70

Please sign in to comment.