File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
packages/vee-validate/src Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ export interface PrivateFormContext<TValues extends GenericObject = GenericObjec
249249 ) : PathState < PathValue < TValues , TPath > > ;
250250 getPathState < TPath extends Path < TValues > > ( path : TPath ) : PathState < PathValue < TValues , TPath > > | undefined ;
251251 getAllPathStates ( ) : PathState [ ] ;
252- removePathState < TPath extends Path < TValues > > ( path : TPath ) : void ;
252+ removePathState < TPath extends Path < TValues > > ( path : TPath , id : number ) : void ;
253253 unsetPathValue < TPath extends Path < TValues > > ( path : TPath ) : void ;
254254 markForUnmount ( path : string ) : void ;
255255}
Original file line number Diff line number Diff line change @@ -407,7 +407,7 @@ function _useField<TValue = unknown>(
407407 const shouldKeepValue = unref ( field . keepValueOnUnmount ) ?? unref ( form . keepValuesOnUnmount ) ;
408408 const path = unravel ( name ) ;
409409 if ( shouldKeepValue || ! form || flags . pendingUnmount [ field . id ] ) {
410- form ?. removePathState ( path ) ;
410+ form ?. removePathState ( path , id ) ;
411411
412412 return ;
413413 }
@@ -437,7 +437,7 @@ function _useField<TValue = unknown>(
437437 form . unsetPathValue ( path ) ;
438438 }
439439
440- form . removePathState ( path ) ;
440+ form . removePathState ( path , id ) ;
441441 } ) ;
442442
443443 return field ;
Original file line number Diff line number Diff line change @@ -456,7 +456,7 @@ export function useForm<
456456 const handleSubmit : typeof handleSubmitImpl & { withControlled : typeof handleSubmitImpl } = handleSubmitImpl as any ;
457457 handleSubmit . withControlled = makeSubmissionFactory ( true ) ;
458458
459- function removePathState < TPath extends Path < TValues > > ( path : TPath ) {
459+ function removePathState < TPath extends Path < TValues > > ( path : TPath , id : number ) {
460460 const idx = pathStates . value . findIndex ( s => s . path === path ) ;
461461 const pathState = pathStates . value [ idx ] ;
462462 if ( idx === - 1 || ! pathState ) {
@@ -467,6 +467,15 @@ export function useForm<
467467 pathState . fieldsCount -- ;
468468 }
469469
470+ if ( Array . isArray ( pathState . id ) ) {
471+ const idIndex = pathState . id . indexOf ( id ) ;
472+ if ( idIndex >= 0 ) {
473+ pathState . id . splice ( idIndex , 1 ) ;
474+ }
475+
476+ delete pathState . __flags . pendingUnmount [ id ] ;
477+ }
478+
470479 if ( ! pathState . multiple || pathState . fieldsCount <= 0 ) {
471480 pathStates . value . splice ( idx , 1 ) ;
472481 unsetInitialValue ( path ) ;
You can’t perform that action at this time.
0 commit comments