File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export const Field = defineComponent({
9191 // For checkboxes and radio buttons it will always be the model value not the `value` attribute
9292 initialValue : hasCheckedAttr ( ctx . attrs . type )
9393 ? props . modelValue
94- : 'modelValue' in ctx . attrs
94+ : 'modelValue' in props
9595 ? props . modelValue
9696 : ctx . attrs . value ,
9797 // Only for checkboxes and radio buttons
Original file line number Diff line number Diff line change @@ -868,4 +868,25 @@ describe('<Field />', () => {
868868 await flushPromises ( ) ;
869869 expect ( model . value ) . toBe ( false ) ;
870870 } ) ;
871+
872+ // #3107
873+ test ( 'sets initial value with v-model' , async ( ) => {
874+ const modelValue = 'allo' ;
875+ const wrapper = mountWithHoc ( {
876+ setup ( ) {
877+ const model = ref ( modelValue ) ;
878+
879+ return { model } ;
880+ } ,
881+ template : `
882+ <div>
883+ <Field name="whatever" v-model="model" />
884+ </div>
885+ ` ,
886+ } ) ;
887+
888+ await flushPromises ( ) ;
889+ const input = wrapper . $el . querySelector ( 'input' ) ;
890+ expect ( input . value ) . toBe ( modelValue ) ;
891+ } ) ;
871892} ) ;
You can’t perform that action at this time.
0 commit comments