Skip to content

Commit

Permalink
Show imported value initially in MUI autocomplete inputs (#1065)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
dalen and ukrbublik authored Jun 19, 2024
1 parent d4690b1 commit ae422a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/mui/modules/widgets/value/MuiAutocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ export default (props) => {
const renderInput = (params) => {
// parity with Antd
const shouldRenderSelected = !multiple && !open;
const selectedTitle = selectedListValue?.title ?? "";
const selectedTitle = selectedListValue?.title ?? value?.toString() ?? "";
const shouldHide = multiple && !open;
const value = shouldRenderSelected ? selectedTitle : (shouldHide ? "" : inputValue ?? "");
const renderValue = shouldRenderSelected ? selectedTitle : (shouldHide ? "" : inputValue ?? value?.toString() ?? "");
return (
<TextField
variant="standard"
{...params}
inputProps={{
...params.inputProps,
value,
"aria-label": ariaLabel,
...params.inputProps,
value: renderValue,
}}
InputProps={{
...params.InputProps,
Expand Down

0 comments on commit ae422a0

Please sign in to comment.