-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Auto Complete] Clear value issue #4213
Comments
I'm having the same issue in the 0.15.0 release. I'm encountering this under slightly different circumstances where I was trimming the text in searchText after selection and it works but then something seems to overwrite it and the entire selected text comes back. I see something similar when I try to completely clear the field. The field is cleared temporarily and then the value selected from the dropdown returns. |
I've created a simple example using the example code from the documentation. This will first clear the control then write back the selected value. |
Removed setting the searchText state from the menu close function and moved the newRequest event after the menu close so that it can be used to overwrite the selected value. Closes mui#4213
Removed setting the searchText state from the menu close function and moved the newRequest event after the menu close so that it can be used to overwrite the selected value. Closes mui#4213
any further action on this issue? Clearing the display value after selecting seems quite important, if the auto complete component is used as a search box |
As a workaround I do
in the callback. In this case it works. |
@priezz Thanks a lot man. Spent a whole day trying to figure this out. |
It should be fixed now. The |
Try this : because I think the function should test the length of the string (BUG ?) |
I could use some help, <Autocomplete
onChange={(event, selectedValue) => setFieldValue('SerialNumber', selectedValue, true)}
clearText = 'Clear'
options={getSerials.serials.map((routers) => serials.SerialNumber)}
autoComplete
openOnFocus
noOptionsText = 'No serial number to match your search'
renderInput={(params) => (
<TextField
{...params}
label="Search/Enter serial number"
required
name="SerialNumber"
helperText={
errors.SerialNumber || null
}
variant="outlined"
value={values.SerialNumber}
SelectProps={{ native: true }}
/>
)}
/> |
@TheCodeNinja254 Look into how you can control the value of the component, alternatively, you can ask on Stackoverflow. |
Problem description
When i try to clear the value of the TextField passing searchText props, after select one item from the menu, the value want change.
I'm using the onNewRequest callback, but it's called before setState with selected value.
Also trying to change searchText props with a setTimeout (after the setState function has been called), the check in componentWillReceiveProps doesn't let the state to be changed.
Steps to reproduce
You can see that the value doesn't change as its searchText props.
Versions
The text was updated successfully, but these errors were encountered: