Skip to content

Commit

Permalink
enhancement(Select) refactor for single selected option since after d…
Browse files Browse the repository at this point in the history
…ropdown render #479
  • Loading branch information
gselderslaghs committed Jan 2, 2025
1 parent 248d4a1 commit aa9c828
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ export class Autocomplete extends Component<AutocompleteOptions> {

// Sketchy removal of dropdown click handler
this.el.removeEventListener('click', this.dropdown._handleClick);
if(!this.options.isMultiSelect && !(this.options.selected.length === 0)) {
const selectedValue = this.menuItems.filter((value) => value.id === this.selectedValues[0].id);
this.el.value = selectedValue[0].text;
}
// Set Value if already set in HTML
if (this.el.value) this.selectOption(this.el.value);
// Add StatusInfo
Expand Down Expand Up @@ -383,9 +387,6 @@ export class Autocomplete extends Component<AutocompleteOptions> {
'display:grid; grid-auto-flow: column; user-select: none; align-items: center;'
);
// Checkbox
if(!this.options.isMultiSelect && this.options.selected) {
this.selectOption(this.selectedValues.map((value) => value.id)[0]);
}
if (this.options.isMultiSelect) {
item.innerHTML = `
<div class="item-selection" style="text-align:center;">
Expand Down

0 comments on commit aa9c828

Please sign in to comment.