@@ -82,14 +82,6 @@ export function useSelectRoot<T>(params: useSelectRoot.Parameters<T>): useSelect
82
82
83
83
const isValueControlled = params . value !== undefined ;
84
84
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
-
93
85
const listRef = React . useRef < Array < HTMLElement | null > > ( [ ] ) ;
94
86
const labelsRef = React . useRef < Array < string | null > > ( [ ] ) ;
95
87
const popupRef = React . useRef < HTMLDivElement | null > ( null ) ;
@@ -118,6 +110,14 @@ export function useSelectRoot<T>(params: useSelectRoot.Parameters<T>): useSelect
118
110
const controlRef = useLatestRef ( triggerElement ) ;
119
111
const commitValidation = fieldControlValidation . commitValidation ;
120
112
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
+
121
121
useField ( {
122
122
id,
123
123
commitValidation,
@@ -144,7 +144,7 @@ export function useSelectRoot<T>(params: useSelectRoot.Parameters<T>): useSelect
144
144
if ( prevValueRef . current !== value ) {
145
145
updateValue ( value ) ;
146
146
}
147
- } , [ updateValue , value ] ) ;
147
+ } , [ setFilled , updateValue , value ] ) ;
148
148
149
149
useModernLayoutEffect ( ( ) => {
150
150
prevValueRef . current = value ;
0 commit comments