Skip to content

Commit

Permalink
feature(Autocomplete) implemented selectOptions to allow multiple ite…
Browse files Browse the repository at this point in the history
…m selection by method call materializecss#552
  • Loading branch information
gselderslaghs committed Jan 6, 2025
1 parent 65ddf18 commit 2c93bd2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ export class Autocomplete extends Component<AutocompleteOptions> {

/**
* Sets selected values.
* @deprecated @see https://github.com/materializecss/materialize/issues/552
* @param entries
*/
setValues(entries: AutocompleteData[]) {
Expand Down Expand Up @@ -564,4 +565,13 @@ export class Autocomplete extends Component<AutocompleteOptions> {
this._updateSelectedInfo();
this._triggerChanged();
}

selectOptions(ids: []) {
const entries = this.menuItems.filter(
(item) => !(ids.indexOf(<never>item.id) === -1)
);
if (!entries) return;
this.selectedValues = entries;
this._renderDropdown();
}
}

0 comments on commit 2c93bd2

Please sign in to comment.