-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete multiple tags are not rendering when value exists and options is empty Array #276
Comments
@tt0mmy, the link https://codesandbox.io/p/sandbox/great-minsky-f8jvcn?file=%2Fsrc%2FDemo.tsx%3A23%2C41 is not accessible. Could you set up a new CodeSandbox? |
can u try this again https://codesandbox.io/p/sandbox/great-minsky-f8jvcn |
@tt0mmy add multiple prop to the Let me know if this helps. <AutocompleteElement
name="testing"
label="TESTING"
options={opts ?? []}
required
textFieldProps={{
error: true,
helperText: "Helper text goes here",
}}
multiple
autocompleteProps={{
size: "small",
clearOnBlur: true,
freeSolo: true,
onInputChange(event, value, reason) {
setReason(value);
setTimeout(() => {
setOpts((previous) => [
...previous,
{
label: `${Math.random().toString()}`,
id: `${Math.random().toString()}`,
},
]);
}, 300);
},
}}
/> |
@sadik-malik this doesn't really works as it populates the opts with partial, multiple and repeating options that are redundant, an option should be added on "commit" not on value change. I dont think there is a good way to use freesolo right now |
Duplicates
Latest version
Current behavior 😯
The
AutocompleteElement
tags are not rendering properly compared to the regular controlledAutocomplete
from @mui/materialExpected behavior 🤔
The tags should be rendered properly like it did in version 6.
I suspect it's because of this https://github.com/dohomi/react-hook-form-mui/blob/master/packages/rhf-mui/src/AutocompleteElement.tsx#L210
Can we return just
newValue
instead of mapping it tomatchOptionByValue
?One workaround is to always include the
transform
prop.Steps to reproduce 🕹
The
AutcompleteElement
should render the tags like theAutocomplete
component. When the value is present and the options are empty Array, the tags are still rendered properly in the regularAutocomplete
component. This behavior should be the same for theAutocompleteElement
component.https://codesandbox.io/p/sandbox/great-minsky-f8jvcn?file=%2Fsrc%2FDemo.tsx%3A23%2C41
The text was updated successfully, but these errors were encountered: