Itvisors / mendix-AutocompleteMultiselect

Auto complete widget where multiple options can be selected.
Other
2 stars 2 forks source link

Custom search in single selection mode #6

Closed sergiuszwoznicki closed 1 year ago

sergiuszwoznicki commented 1 year ago

Hi,

An error is thrown if using custom search in single selection mode in this line: https://github.com/Itvisors/mendix-AutocompleteMultiselect/blob/main/src/AutocompleteMultiselect.jsx#L65

as this.optionsSelected is not an array (but a null) in this case - because of logic from this line: https://github.com/Itvisors/mendix-AutocompleteMultiselect/blob/main/src/AutocompleteMultiselect.jsx#L59

and hence calling .filter() on it triggers an error.

Repro steps:

Fix:

Change https://github.com/Itvisors/mendix-AutocompleteMultiselect/blob/main/src/AutocompleteMultiselect.jsx#L65 into:

                            const optionsSelectedAsArray = this.props.multiple
                                ? this.optionsSelected
                                : this.optionsSelected === null ? [] : [this.optionsSelected];
                            const optionsSelectedNotInList = optionsSelectedAsArray.filter(...
jeuhen commented 1 year ago

Hi,

Thanks for your feedback and solution. I just released a new version. Please let me know if something is not working :)

sergiuszwoznicki commented 1 year ago

Hi, thanks for your update. Verified: it works well (also with another issue we've found later with default options - fixed by you in line https://github.com/Itvisors/mendix-AutocompleteMultiselect/blob/main/src/AutocompleteMultiselect.jsx#L233).