Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added mendix-AutocompleteMultiselect - Verknüpfung.lnk
Binary file not shown.
8 changes: 4 additions & 4 deletions src/AutocompleteMultiselect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ export default class AutocompleteMultiselect extends Component {
? this.optionsSelected
: this.optionsSelected === null ? [] : [this.optionsSelected];
const optionsSelectedNotInList = optionsSelectedAsArray.filter(selectedOption => {
return dataParsed.find(option => option.title === selectedOption.title && option.key === selectedOption.key) === undefined;
return dataParsed.find(option => ((option.key !== undefined && option.key.length > 0) || option.title === selectedOption.title) && option.key === selectedOption.key) === undefined;
});
dataParsed = dataParsed.concat(optionsSelectedNotInList);
} else {
if (this.props.multiple) {
// Else check if optionSelected are still available. This is done since it can be the case that the options have been changed.
this.optionsSelected = this.optionsSelected.filter(selectedOption => {
return dataParsed.find(option => option.title === selectedOption.title && option.key === selectedOption.key) !== undefined;
return dataParsed.find(option => ((option.key !== undefined && option.key.length > 0) || option.title === selectedOption.title) && option.key === selectedOption.key) !== undefined;
});
} else if (this.optionsSelected !== null) {
this.optionsSelected = dataParsed.find(option => option.title === this.optionsSelected.title && option.key === this.optionsSelected.key);
this.optionsSelected = dataParsed.find(option => ((option.key !== undefined && option.key.length > 0) || option.title === this.optionsSelected.title) && option.key === this.optionsSelected.key);
} if (this.optionsSelected === undefined) {
this.optionsSelected = null;
}
Expand Down Expand Up @@ -149,7 +149,7 @@ export default class AutocompleteMultiselect extends Component {
} else {
// Else check if option is selected (based on the title). This is done since it can be the case that the options have been changed.
if (multiSelect) {
if (this.optionsSelected.find(option => option.title === optionTitle)) {
if (this.optionsSelected.find(findoption => ((findoption.key !== undefined && option.key.length > 0) || findoption.title === optionTitle) && findoption.key === option.key)) {
optionsSelected.push(option);
}
} else if (this.optionsSelected !== null) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/AutocompleteUI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class AutocompleteUI extends Component {
loading = {this.props.loading}
loadingText = {this.props.loadingText}
onInputChange={ this.props.onInputChange}
getOptionSelected={(option, value) => option.title === value.title && option.key === value.key}
getOptionSelected={(option, value) => ((option.key !== undefined && option.key.length > 0) || option.title === value.title) && option.key === value.key}
renderOption={(option, { selected }) => (
<Fragment>
{this.props.showCheckboxes ? <Checkbox
Expand Down