@etsoo/materialui 1.1.73 → 1.1.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ComboBoxPro.js +5 -3
- package/package.json +1 -1
- package/src/ComboBoxPro.tsx +4 -3
package/lib/ComboBoxPro.js
CHANGED
|
@@ -14,7 +14,7 @@ export function ComboBoxPro(props) {
|
|
|
14
14
|
const [localValue, setValue] = React.useState(null);
|
|
15
15
|
const [loading, setLoading] = React.useState(false);
|
|
16
16
|
React.useEffect(() => {
|
|
17
|
-
if (value
|
|
17
|
+
if (value === undefined)
|
|
18
18
|
return;
|
|
19
19
|
setValue(value);
|
|
20
20
|
}, [value]);
|
|
@@ -24,6 +24,8 @@ export function ComboBoxPro(props) {
|
|
|
24
24
|
const option = localOptions.find((option) => option.id === idValue);
|
|
25
25
|
if (option)
|
|
26
26
|
setValue(option);
|
|
27
|
+
else
|
|
28
|
+
setValue(null);
|
|
27
29
|
}, [localOptions]);
|
|
28
30
|
React.useEffect(() => {
|
|
29
31
|
if (typeof options === "function") {
|
|
@@ -38,12 +40,12 @@ export function ComboBoxPro(props) {
|
|
|
38
40
|
setOptions(options);
|
|
39
41
|
}
|
|
40
42
|
}, [options]);
|
|
41
|
-
return (React.createElement(Autocomplete, { id: name, value: localValue, open: open, freeSolo: true, clearOnBlur: false, onOpen: () => {
|
|
43
|
+
return (React.createElement(Autocomplete, { id: name, value: localValue == null ? "" : localValue, open: open, freeSolo: true, clearOnBlur: false, onOpen: () => {
|
|
42
44
|
setOpen(true);
|
|
43
45
|
}, onClose: () => {
|
|
44
46
|
setOpen(false);
|
|
45
47
|
}, options: localOptions, loading: loading, openOnFocus: openOnFocus, renderInput: (params) => (React.createElement(InputField, { ...inputProps, ...params, label: label, name: name, onBlur: (event) => {
|
|
46
|
-
if (onChange)
|
|
48
|
+
if (localValue == null && onChange)
|
|
47
49
|
onChange(event, event.target.value, "blur", undefined);
|
|
48
50
|
} })), getOptionLabel: (item) => typeof item === "object" ? getLabel(item) : item, isOptionEqualToValue: (option, value) => option.id === value.id, noOptionsText: noOptionsText, loadingText: loadingText, openText: openText, onChange: (event, value, reason, details) => {
|
|
49
51
|
setValue(value);
|
package/package.json
CHANGED
package/src/ComboBoxPro.tsx
CHANGED
|
@@ -72,7 +72,7 @@ export function ComboBoxPro<D extends DataType = DataType>(
|
|
|
72
72
|
const [loading, setLoading] = React.useState(false);
|
|
73
73
|
|
|
74
74
|
React.useEffect(() => {
|
|
75
|
-
if (value
|
|
75
|
+
if (value === undefined) return;
|
|
76
76
|
setValue(value);
|
|
77
77
|
}, [value]);
|
|
78
78
|
|
|
@@ -80,6 +80,7 @@ export function ComboBoxPro<D extends DataType = DataType>(
|
|
|
80
80
|
if (idValue == null) return;
|
|
81
81
|
const option = localOptions.find((option) => option.id === idValue);
|
|
82
82
|
if (option) setValue(option);
|
|
83
|
+
else setValue(null);
|
|
83
84
|
}, [localOptions]);
|
|
84
85
|
|
|
85
86
|
React.useEffect(() => {
|
|
@@ -97,7 +98,7 @@ export function ComboBoxPro<D extends DataType = DataType>(
|
|
|
97
98
|
return (
|
|
98
99
|
<Autocomplete<D, false, false, true>
|
|
99
100
|
id={name}
|
|
100
|
-
value={localValue}
|
|
101
|
+
value={localValue == null ? "" : localValue}
|
|
101
102
|
open={open}
|
|
102
103
|
freeSolo
|
|
103
104
|
clearOnBlur={false}
|
|
@@ -117,7 +118,7 @@ export function ComboBoxPro<D extends DataType = DataType>(
|
|
|
117
118
|
label={label}
|
|
118
119
|
name={name}
|
|
119
120
|
onBlur={(event) => {
|
|
120
|
-
if (onChange)
|
|
121
|
+
if (localValue == null && onChange)
|
|
121
122
|
onChange(event, event.target.value, "blur", undefined);
|
|
122
123
|
}}
|
|
123
124
|
/>
|