@@ -596,7 +596,6 @@ function setPageToError(pageIndex: number, page?: Page, source = 'submit'): void
596596let debounceTimer: ReturnType <typeof setTimeout >;
597597
598598function onFieldValidate(field : Field , next : () => void ): void {
599- const errors = $useForm .errorBag as ValidateResult [' errors' ];
600599 const shouldAutoPage = (field .autoPage || settings .value .autoPage ? next : null ) as () => void ;
601600
602601 // If autoPage //
@@ -606,20 +605,17 @@ function onFieldValidate(field: Field, next: () => void): void {
606605 // First validate the page before proceeding to the next page //
607606 $useForm .validate ()
608607 .then ((res : ValidateResult ) => {
609- if (res .valid ) {
610- // debounce next //
611- clearTimeout (debounceTimer );
612- debounceTimer = setTimeout (() => {
613- checkForPageErrors (errors , ' field' , shouldAutoPage );
614- }, (field ?.autoPageDelay ?? settings .value ?.autoPageDelay ));
615-
616- return ;
617- }
618-
619- const page = computedPages .value [currentPageIdx .value ];
620- const pageIndex = computedPages .value .findIndex ((p ) => p === page );
621-
622- setPageToError (pageIndex , page , ' validating' );
608+ // `validate()` covers the whole form, so fields on later pages
609+ // are still invalid while the user is on an earlier one. Only
610+ // the current page's errors may block auto paging, which is
611+ // what `checkForPageErrors` filters on (same as the next button).
612+ const errors = res .errors as unknown as ValidateResult [' errors' ];
613+
614+ // debounce next //
615+ clearTimeout (debounceTimer );
616+ debounceTimer = setTimeout (() => {
617+ checkForPageErrors (errors , ' field' , shouldAutoPage );
618+ }, (field ?.autoPageDelay ?? settings .value ?.autoPageDelay ));
623619 })
624620 .catch ((error : Error ) => {
625621 console .error (' Error' , error );
0 commit comments