kotlin-wrappers icon indicating copy to clipboard operation
kotlin-wrappers copied to clipboard

MUI Autocomplete onChange: Wrong `value` type

Open hofi99 opened this issue 6 months ago • 0 comments

I noticed that since [this] (https://github.com/JetBrains/kotlin-wrappers/pull/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.
}

hofi99 avatar Aug 14 '24 09:08 hofi99