Skip to content
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

Clearing of AutoComplete lacks callback #18957

Closed
megupta opened this issue Dec 22, 2019 · 3 comments · Fixed by #18897
Closed

Clearing of AutoComplete lacks callback #18957

megupta opened this issue Dec 22, 2019 · 3 comments · Fixed by #18897
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module!

Comments

@megupta
Copy link

megupta commented Dec 22, 2019

  • [ x ] The issue is present in the latest release.
  • [ x ] I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Clearing the TextField by use of AutoComplete's clear indicator does not trigger any callbacks (onInputChange, onChange, onOpen, onClose). It also does not trigger the TextField's onChange callback either.

Expected Behavior 🤔

Trigger onChange, onInputChange or a new callback if required.

Steps to Reproduce 🕹

const onChangeEvent = (event) => {
    console.log(event);
};

const onInputChangeEvent = (event, value) => {
    console.log(event);
};

<Autocomplete
    options={["A", "B", "C", "D"]}
    onChange={ onChangeEvent }
    onInputChange={ onInputChangeEvent }
    renderInput={ (params) => (
        <TextField { ...params } label="Field" variant="outlined" fullWidth />
    )
    }
    freeSolo
/>

Steps:

  1. Select option in TextInput or type in text
  2. Press the clear button
  3. Check console for expected event

Context 🔦

Tracking the state of the TextField will require querying of the TextField on submission.

Your Environment 🌎

Tech Version
Material-UI 4.8.0
React 16.8.6
Browser Chrome 79
TypeScript 3.7.3
@mbrookes mbrookes added component: autocomplete This is the name of the generic UI component, not the React module! new feature New feature or request labels Dec 22, 2019
@oliviertassinari
Copy link
Member

I believe this bug was fixed in https://github.com/mui-org/material-ui/pull/18897/files#diff-78d0a2ffffcd7327f1b0cfa0acea49c4R518.

@megupta
Copy link
Author

megupta commented Dec 24, 2019

It does look like it's fixed with that code.

@megupta megupta closed this as completed Dec 24, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 24, 2019

Great :). Released under @material-ui/lab, v4.0.0-alpha.37.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work and removed new feature New feature or request labels Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants