less aggressive default value (#7844)

This commit is contained in:
Vadim Ogievetsky 2019-06-07 08:31:21 -07:00 committed by Fangjin Yang
parent ee0d4ea589
commit 0ca867efbf
1 changed files with 8 additions and 3 deletions

View File

@ -173,11 +173,16 @@ export class AutoForm<T extends Record<string, any>> extends React.Component<Aut
</Menu> : </Menu> :
undefined; undefined;
const modalValue = deepGet(model as any, field.name);
return <InputGroup return <InputGroup
value={deepGet(model as any, field.name) || field.defaultValue || ''} value={modalValue != null ? modalValue : (field.defaultValue || '')}
onChange={(e: any) => { onChange={(e: any) => {
const v = e.target.value; let v = e.target.value;
this.fieldChange(field, v === '' ? undefined : (sanitize ? sanitize(v) : v)); if (sanitize) v = sanitize(v);
this.fieldChange(field, v);
}}
onBlur={() => {
if (modalValue === '') this.fieldChange(field, undefined);
}} }}
placeholder={field.placeholder} placeholder={field.placeholder}
rightElement={ rightElement={