Skip to content

Commit 3b41c70

Browse files
committed
fix(select): 🩹 update fork ref declaration
1 parent 31f7e71 commit 3b41c70

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/select/SelectProps.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ export const useSelectProps = ({
6969
const selectInlineStyles = React.useRef<Record<string, any>>({});
7070
let prefixRef = React.useRef<HTMLElement>(null);
7171
let suffixRef = React.useRef<HTMLElement>(null);
72-
prefixRef = useForkRef(
73-
prefixRef,
74-
componentProps?.prefixProps?.ref,
75-
) as unknown as React.RefObject<HTMLElement>;
76-
suffixRef = useForkRef(
77-
suffixRef,
78-
componentProps?.suffixProps?.ref,
79-
) as unknown as React.RefObject<HTMLElement>;
8072

8173
useSafeLayoutEffect(() => {
8274
let key = "";
@@ -124,26 +116,34 @@ export const useSelectProps = ({
124116
[componentProps.baseProps, disabled, finalChildren, restProps, uiProps],
125117
);
126118

119+
const _prefixRef = useForkRef(
120+
prefixRef,
121+
componentProps?.prefixProps?.ref,
122+
) as unknown as React.RefObject<HTMLElement>;
127123
const prefixProps: SelectPrefixProps = React.useMemo(
128124
() => ({
129125
...uiProps,
130126
disabled,
131127
...componentProps.prefixProps,
132-
ref: prefixRef,
128+
ref: _prefixRef,
133129
children: withIconA11y(uiProps.prefix, uiProps),
134130
}),
135-
[componentProps.prefixProps, disabled, uiProps],
131+
[_prefixRef, componentProps.prefixProps, disabled, uiProps],
136132
);
137133

134+
const _suffixRef = useForkRef(
135+
suffixRef,
136+
componentProps?.suffixProps?.ref,
137+
) as unknown as React.RefObject<HTMLElement>;
138138
const suffixProps: SelectSuffixProps = React.useMemo(
139139
() => ({
140140
...uiProps,
141141
disabled,
142142
...componentProps.suffixProps,
143-
ref: suffixRef,
143+
ref: _suffixRef,
144144
children: uiProps.suffix,
145145
}),
146-
[componentProps.suffixProps, disabled, uiProps],
146+
[_suffixRef, componentProps.suffixProps, disabled, uiProps],
147147
);
148148
return {
149149
uiProps,

0 commit comments

Comments
 (0)