1- import React , { useRef , useImperativeHandle } from 'react' ;
1+ import React , { useEffect , useImperativeHandle , useRef } from 'react' ;
22import classNames from 'classnames' ;
33import useConfig from '../hooks/useConfig' ;
44import noop from '../_util/noop' ;
@@ -38,7 +38,6 @@ const Form = forwardRefWithStatics(
3838 resetType,
3939 rules,
4040 errorMessage = globalFormConfig . errorMessage ,
41- preventSubmitDefault,
4241 disabled,
4342 children,
4443 id,
@@ -61,7 +60,7 @@ const Form = forwardRefWithStatics(
6160 form ?. getInternalHooks ?.( HOOK_MARK ) ?. setForm ?.( formInstance ) ;
6261
6362 // form 初始化后清空队列
64- React . useEffect ( ( ) => {
63+ useEffect ( ( ) => {
6564 form ?. getInternalHooks ?.( HOOK_MARK ) ?. flashQueue ?.( ) ;
6665 } , [ form ] ) ;
6766
@@ -79,15 +78,6 @@ const Form = forwardRefWithStatics(
7978 onValuesChange ( changedValue , allFields ) ;
8079 }
8180
82- function onKeyDownHandler ( e : React . KeyboardEvent < HTMLFormElement > ) {
83- // 禁用 input 输入框回车自动提交 form
84- if ( ( e . target as Element ) . tagName . toLowerCase ( ) !== 'input' ) return ;
85- if ( preventSubmitDefault && e . key === 'Enter' ) {
86- e . preventDefault ?.( ) ;
87- e . stopPropagation ?.( ) ;
88- }
89- }
90-
9181 return (
9282 < FormContext . Provider
9383 value = { {
@@ -118,7 +108,6 @@ const Form = forwardRefWithStatics(
118108 className = { formClass }
119109 onSubmit = { formInstance . submit }
120110 onReset = { onResetHandler }
121- onKeyDown = { onKeyDownHandler }
122111 >
123112 { children }
124113 </ form >
0 commit comments