Skip to content

Clearing of AutoComplete lacks callback #18957

@megupta

Description

@megupta
  • [ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: autocompleteChanges related to the autocomplete. This includes ComboBox.type: bugIt doesn't behave as expected.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions