Skip to content

Commit 6c48601

Browse files
committed
Lint
1 parent 8a633da commit 6c48601

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

packages/react/src/select/root/SelectRoot.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe('<Select.Root />', () => {
134134

135135
it('should not update the internal value if the controlled value prop does not change', async () => {
136136
const onValueChange = spy();
137-
const { user } = await render(
137+
await render(
138138
<Select.Root value="a" onValueChange={onValueChange}>
139139
<Select.Trigger data-testid="trigger">
140140
<Select.Value>a</Select.Value>

packages/react/src/select/root/useSelectRoot.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,6 @@ export function useSelectRoot<T>(params: useSelectRoot.Parameters<T>): useSelect
8282

8383
const isValueControlled = params.value !== undefined;
8484

85-
const updateValue = useEventCallback((value: any) => {
86-
const index = valuesRef.current.indexOf(value);
87-
setSelectedIndex(index === -1 ? null : index);
88-
setLabel(labelsRef.current[index] ?? '');
89-
clearErrors(name);
90-
setDirty(value !== validityData.initialValue);
91-
});
92-
9385
const listRef = React.useRef<Array<HTMLElement | null>>([]);
9486
const labelsRef = React.useRef<Array<string | null>>([]);
9587
const popupRef = React.useRef<HTMLDivElement | null>(null);
@@ -118,6 +110,14 @@ export function useSelectRoot<T>(params: useSelectRoot.Parameters<T>): useSelect
118110
const controlRef = useLatestRef(triggerElement);
119111
const commitValidation = fieldControlValidation.commitValidation;
120112

113+
const updateValue = useEventCallback((nextValue: any) => {
114+
const index = valuesRef.current.indexOf(nextValue);
115+
setSelectedIndex(index === -1 ? null : index);
116+
setLabel(labelsRef.current[index] ?? '');
117+
clearErrors(name);
118+
setDirty(nextValue !== validityData.initialValue);
119+
});
120+
121121
useField({
122122
id,
123123
commitValidation,
@@ -144,7 +144,7 @@ export function useSelectRoot<T>(params: useSelectRoot.Parameters<T>): useSelect
144144
if (prevValueRef.current !== value) {
145145
updateValue(value);
146146
}
147-
}, [updateValue, value]);
147+
}, [setFilled, updateValue, value]);
148148

149149
useModernLayoutEffect(() => {
150150
prevValueRef.current = value;

0 commit comments

Comments
 (0)