cfnz / muirwik

Muirwik - a Material UI React wrapper written in Kotlin
Mozilla Public License 2.0
132 stars 25 forks source link

mAutoComplete: defaultValue props type #66

Closed sbednarska closed 3 years ago

sbednarska commented 3 years ago

Hi, According material UI documentation I should be able to set an array as default value. The defaultValue type is now set to T, so when I'm using mAutoComplete with multiple = true I got an error:

"Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).some is not a function"

  var filteredOptions = popupOpen ? filterOptions(options.filter(function (option) {
    if (filterSelectedOptions && (multiple ? value : [value]).some(function (value2) {
      return value2 !== null && getOptionSelected(option, value2);
    })) {
      return false;
    }
cfnz commented 3 years ago

AutoComplete uses union types which makes it a bit tricky in Kotlin. I have separated out mAutoComplete and mAutoCompleteMultiValue to better handle both use cases.

Note there is still something strange going on with this component... in the test app you will see I have commented out some code that causes issues, but I have no idea why it causes the issues at this stage...

Not sure if this will help out with your issue...

sbednarska commented 3 years ago

Thank you for your answer, I will check mAutoCompleteMultiValue after updating muirwik in my project. I used notation attrs.as Dynamic().default Value = and that's enough for me for now.