Skip to content

Commit

Permalink
fix(Autocomplete) remove conditional check on html and static handlin…
Browse files Browse the repository at this point in the history
…g of toggling checkbox since list is empty if minLength option is greater then 0 materializecss#479
  • Loading branch information
gselderslaghs committed Jan 4, 2025
1 parent 9afcf38 commit 507ece8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,16 +552,18 @@ export class Autocomplete extends Component<AutocompleteOptions> {
const entry = this.menuItems.find((item) => item.id == id);
if (!entry) return;
// Toggle Checkbox
const li = this.container.querySelector('li[data-id="' + id + '"]');
if (!li) return;
/* const li = this.container.querySelector('li[data-id="' + id + '"]');
if (!li) return;*/
if (this.options.isMultiSelect) {
const checkbox = <HTMLInputElement | null>li.querySelector('input[type="checkbox"]');
/* const checkbox = <HTMLInputElement | null>li.querySelector('input[type="checkbox"]');
checkbox.checked = !checkbox.checked;
if (checkbox.checked) this.selectedValues.push(entry);
else
this.selectedValues = this.selectedValues.filter(
(selectedEntry) => selectedEntry.id !== entry.id
);
);*/
this.selectedValues.push(entry);
this._renderDropdown();
this.el.focus();
} else {
// Single-Select
Expand Down

0 comments on commit 507ece8

Please sign in to comment.