fix: set to null when text field is empty

This commit is contained in:
chenos 2021-01-07 12:48:24 +08:00
parent 84e4df4086
commit 285cf34c6a

View File

@ -6,7 +6,15 @@ import { acceptEnum, mapStyledProps, mapTextComponent } from '../shared'
export const Input = connect<'TextArea'>({ export const Input = connect<'TextArea'>({
getProps: mapStyledProps, getProps: mapStyledProps,
getComponent: mapTextComponent getComponent: mapTextComponent
})(acceptEnum(AntdInput)) })(acceptEnum(({onChange, ...restProps}) => (
<AntdInput
{...restProps}
onChange={(e) => {
// 文本字段,如果空要 null 处理
onChange(e.target.value ? e : null);
}}
/>
)))
Input.TextArea = connect({ Input.TextArea = connect({
getProps: mapStyledProps, getProps: mapStyledProps,