Skip to content

Commit 5879273

Browse files
authored
fix(orchestrator): preserve ActiveTextInput value with autocomplete (#776)
Signed-off-by: Marek Libra <marek.libra@gmail.com>
1 parent 4a25a85 commit 5879273

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

workspaces/orchestrator/plugins/orchestrator-form-widgets/src/widgets/ActiveTextInput.tsx

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export const ActiveTextInput: Widget<
5050
const { formData } = formContext;
5151

5252
const { label, value, onChange } = props;
53-
5453
const uiProps = useMemo(
5554
() => (props.options?.props ?? {}) as JsonObject,
5655
[props.options?.props],
@@ -98,7 +97,6 @@ export const ActiveTextInput: Widget<
9897
// Not yet ready to fetch
9998
return;
10099
}
101-
102100
const firstTime = value === undefined;
103101
if (!firstTime && !autocompleteSelector) {
104102
// No need to fetch
@@ -179,27 +177,21 @@ export const ActiveTextInput: Widget<
179177
}
180178

181179
if (autocompleteOptions) {
182-
const renderInput = (params: AutocompleteRenderInputParams) => {
183-
const autocompleteValue = (
184-
params.inputProps as unknown as { value: string }
185-
).value;
186-
if (autocompleteValue !== value) {
187-
handleChange(autocompleteValue);
188-
}
189-
190-
return (
191-
<TextField
192-
{...params}
193-
value={value ?? ''}
194-
onChange={event => handleChange(event.target.value)}
195-
label={label}
196-
/>
197-
);
198-
};
180+
const renderInput = (params: AutocompleteRenderInputParams) => (
181+
<TextField
182+
{...params}
183+
onChange={event => handleChange(event.target.value)}
184+
label={label}
185+
/>
186+
);
199187

200188
return (
201189
<FormControl variant="outlined" fullWidth>
202-
<Autocomplete options={autocompleteOptions} renderInput={renderInput} />
190+
<Autocomplete
191+
options={autocompleteOptions}
192+
value={value}
193+
renderInput={renderInput}
194+
/>
203195
</FormControl>
204196
);
205197
}

0 commit comments

Comments
 (0)