Skip to content

Commit ae422a0

Browse files
dalenukrbublik
andauthored
Show imported value initially in MUI autocomplete inputs (#1065)
* Show imported value initially in MUI autocomplete inputs When importing a query from for example json logic, show the imported value initially in autocomplete inputs that use an asyncFetch. Before this they would show no value at all until you clicked on them and they loaded all the options. * fix --------- Co-authored-by: ukrbublik <ukrbublik@gmail.com>
1 parent d4690b1 commit ae422a0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/mui/modules/widgets/value/MuiAutocomplete.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ export default (props) => {
9999
const renderInput = (params) => {
100100
// parity with Antd
101101
const shouldRenderSelected = !multiple && !open;
102-
const selectedTitle = selectedListValue?.title ?? "";
102+
const selectedTitle = selectedListValue?.title ?? value?.toString() ?? "";
103103
const shouldHide = multiple && !open;
104-
const value = shouldRenderSelected ? selectedTitle : (shouldHide ? "" : inputValue ?? "");
104+
const renderValue = shouldRenderSelected ? selectedTitle : (shouldHide ? "" : inputValue ?? value?.toString() ?? "");
105105
return (
106106
<TextField
107107
variant="standard"
108108
{...params}
109109
inputProps={{
110-
...params.inputProps,
111-
value,
112110
"aria-label": ariaLabel,
111+
...params.inputProps,
112+
value: renderValue,
113113
}}
114114
InputProps={{
115115
...params.InputProps,

0 commit comments

Comments
 (0)