@@ -34,6 +34,7 @@ import FormItemLabel from './FormItemLabel';
3434import FormItemInput from './FormItemInput' ;
3535import type { ValidationRule } from './Form' ;
3636import { useProvideFormItemContext } from './FormItemContext' ;
37+ import useDebounce from './utils/useDebounce' ;
3738
3839const ValidateStatuses = tuple ( 'success' , 'warning' , 'error' , 'validating' , '' ) ;
3940export type ValidateStatus = typeof ValidateStatuses [ number ] ;
@@ -368,15 +369,24 @@ export default defineComponent({
368369 onBeforeUnmount ( ( ) => {
369370 formContext . removeField ( eventKey ) ;
370371 } ) ;
372+ const debounceErrors = useDebounce ( errors ) ;
373+ const mergedValidateStatus = computed ( ( ) => {
374+ if ( props . validateStatus !== undefined ) {
375+ return props . validateStatus ;
376+ } else if ( debounceErrors . value . length ) {
377+ return 'error' ;
378+ }
379+ return validateState . value ;
380+ } ) ;
371381 const itemClassName = computed ( ( ) => ( {
372382 [ `${ prefixCls . value } -item` ] : true ,
373383
374384 // Status
375- [ `${ prefixCls . value } -item-has-feedback` ] : validateState . value && props . hasFeedback ,
376- [ `${ prefixCls . value } -item-has-success` ] : validateState . value === 'success' ,
377- [ `${ prefixCls . value } -item-has-warning` ] : validateState . value === 'warning' ,
378- [ `${ prefixCls . value } -item-has-error` ] : validateState . value === 'error' ,
379- [ `${ prefixCls . value } -item-is-validating` ] : validateState . value === 'validating' ,
385+ [ `${ prefixCls . value } -item-has-feedback` ] : mergedValidateStatus . value && props . hasFeedback ,
386+ [ `${ prefixCls . value } -item-has-success` ] : mergedValidateStatus . value === 'success' ,
387+ [ `${ prefixCls . value } -item-has-warning` ] : mergedValidateStatus . value === 'warning' ,
388+ [ `${ prefixCls . value } -item-has-error` ] : mergedValidateStatus . value === 'error' ,
389+ [ `${ prefixCls . value } -item-is-validating` ] : mergedValidateStatus . value === 'validating' ,
380390 [ `${ prefixCls . value } -item-hidden` ] : props . hidden ,
381391 } ) ) ;
382392 return ( ) => {
@@ -387,7 +397,7 @@ export default defineComponent({
387397 { ...attrs }
388398 class = { [
389399 itemClassName . value ,
390- ( help !== undefined && help !== null ) || errors . value . length
400+ ( help !== undefined && help !== null ) || debounceErrors . value . length
391401 ? `${ prefixCls . value } -item-with-help`
392402 : '' ,
393403 attrs . class ,
@@ -409,10 +419,11 @@ export default defineComponent({
409419 { /* Input Group */ }
410420 < FormItemInput
411421 { ...props }
412- errors = { help !== undefined && help !== null ? toArray ( help ) : errors . value }
422+ errors = {
423+ help !== undefined && help !== null ? toArray ( help ) : debounceErrors . value
424+ }
413425 prefixCls = { prefixCls . value }
414- status = { validateState . value }
415- validateStatus = { validateState . value }
426+ status = { mergedValidateStatus . value }
416427 ref = { inputRef }
417428 help = { help }
418429 extra = { props . extra ?? slots . extra ?.( ) }
0 commit comments