diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-12-05 17:23:44 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-12-05 17:23:44 -0800 |
commit | a4c2f0477dcda2662a3fd268f77a7549dead6e67 (patch) | |
tree | 4782c3456ae181f783d24f9892eec4a2c7f509c2 /modern/src/form/SelectField.js | |
parent | 604eabcd97c6e7ddb42316a5a1fb0abc24e8dc7f (diff) | |
download | trackermap-web-a4c2f0477dcda2662a3fd268f77a7549dead6e67.tar.gz trackermap-web-a4c2f0477dcda2662a3fd268f77a7549dead6e67.tar.bz2 trackermap-web-a4c2f0477dcda2662a3fd268f77a7549dead6e67.zip |
Fix default and empty values (fix #802)
Diffstat (limited to 'modern/src/form/SelectField.js')
-rw-r--r-- | modern/src/form/SelectField.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modern/src/form/SelectField.js b/modern/src/form/SelectField.js index fa51a366..b179c58e 100644 --- a/modern/src/form/SelectField.js +++ b/modern/src/form/SelectField.js @@ -7,7 +7,8 @@ const SelectField = ({ variant, label, multiple, - defaultValue, + value, + emptyValue = 0, onChange, endpoint, data, @@ -31,10 +32,10 @@ const SelectField = ({ <InputLabel>{label}</InputLabel> <Select multiple={multiple} - defaultValue={defaultValue} + value={value} onChange={onChange}> - {!multiple && - <MenuItem value={0}> </MenuItem> + {!multiple && emptyValue !== null && + <MenuItem value={emptyValue}> </MenuItem> } {items.map(item => ( <MenuItem key={keyGetter(item)} value={keyGetter(item)}>{titleGetter(item)}</MenuItem> |