@@ -10,7 +10,7 @@ import { defaultValidateMessages } from './utils/messages';
10
10
import { allPromiseFinish } from './utils/asyncUtil' ;
11
11
import { toArray } from './utils/typeUtil' ;
12
12
import isEqual from 'lodash-es/isEqual' ;
13
- import scrollIntoView from 'scroll-into-view-if-needed' ;
13
+ import scrollIntoView , { Options } from 'scroll-into-view-if-needed' ;
14
14
import initDefaultProps from '../_util/props-util/initDefaultProps' ;
15
15
import { tuple , VueNode } from '../_util/type' ;
16
16
import { ColProps } from '../grid/Col' ;
@@ -56,7 +56,7 @@ export const formProps = {
56
56
validateMessages : PropTypes . object ,
57
57
validateOnRuleChange : PropTypes . looseBool ,
58
58
// 提交失败自动滚动到第一个错误字段
59
- scrollToFirstError : PropTypes . looseBool ,
59
+ scrollToFirstError : { type : [ Boolean , Object ] as PropType < boolean | Options > } ,
60
60
onSubmit : PropTypes . func ,
61
61
onFinish : PropTypes . func ,
62
62
onFinishFailed : PropTypes . func ,
@@ -151,7 +151,11 @@ const Form = defineComponent({
151
151
const { scrollToFirstError } = this ;
152
152
this . $emit ( 'finishFailed' , errorInfo ) ;
153
153
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 ) ;
155
159
}
156
160
} ,
157
161
validate ( ...args : any [ ] ) {
0 commit comments