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

MUI Autocomplete onChange: Wrong value type #2392

Open
hofi99 opened this issue Aug 14, 2024 · 0 comments
Open

MUI Autocomplete onChange: Wrong value type #2392

hofi99 opened this issue Aug 14, 2024 · 0 comments

Comments

@hofi99
Copy link

hofi99 commented Aug 14, 2024

I noticed that since [this] (#2288) PR, the Autocomplete onChange value parameter is Any.
But actually it should be Any? because clearing the Autocomplete can return null.
This leads to a runtime exception after clearing the Autocomplete component when in the onChange value is specified as Any.

E.g. of failing example

Autocomplete<AutocompleteProps<String>> {
  value = state.value
  onChange = { _, value: Any, _, _ -> // This causes the runtime exception.
    value as String
    setState {
      this.value = value
    }
  }
 // etc.
}

E.g. of working example

Autocomplete<AutocompleteProps<String>> {
  value = state.value
  onChange = { _, value: Any?, _, _ ->
    value as String?
    setState {
      this.value = value
    }
  }
 // etc.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant