@@ -10,7 +10,7 @@ import { defaultValidateMessages } from './utils/messages';
1010import { allPromiseFinish } from './utils/asyncUtil' ;
1111import { toArray } from './utils/typeUtil' ;
1212import isEqual from 'lodash-es/isEqual' ;
13- import scrollIntoView from 'scroll-into-view-if-needed' ;
13+ import scrollIntoView , { Options } from 'scroll-into-view-if-needed' ;
1414import initDefaultProps from '../_util/props-util/initDefaultProps' ;
1515import { tuple , VueNode } from '../_util/type' ;
1616import { ColProps } from '../grid/Col' ;
@@ -56,7 +56,7 @@ export const formProps = {
5656 validateMessages : PropTypes . object ,
5757 validateOnRuleChange : PropTypes . looseBool ,
5858 // 提交失败自动滚动到第一个错误字段
59- scrollToFirstError : PropTypes . looseBool ,
59+ scrollToFirstError : { type : [ Boolean , Object ] as PropType < boolean | Options > } ,
6060 onSubmit : PropTypes . func ,
6161 onFinish : PropTypes . func ,
6262 onFinishFailed : PropTypes . func ,
@@ -151,7 +151,11 @@ const Form = defineComponent({
151151 const { scrollToFirstError } = this ;
152152 this . $emit ( 'finishFailed' , errorInfo ) ;
153153 if ( scrollToFirstError && errorInfo . errorFields . length ) {
154- this . scrollToField ( errorInfo . errorFields [ 0 ] . name ) ;
154+ let scrollToFieldOptions : Options = { } ;
155+ if ( typeof scrollToFirstError === 'object' ) {
156+ scrollToFieldOptions = scrollToFirstError ;
157+ }
158+ this . scrollToField ( errorInfo . errorFields [ 0 ] . name , scrollToFieldOptions ) ;
155159 }
156160 } ,
157161 validate ( ...args : any [ ] ) {
0 commit comments