Skip to content

Commit

Permalink
2727-ids-dropdown-value-attribute (fix tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
clayinfor committed Aug 28, 2024
1 parent 983bcc0 commit f7caec2
Show file tree
Hide file tree
Showing 2 changed files with 399 additions and 83 deletions.
9 changes: 6 additions & 3 deletions src/components/ids-dropdown/ids-dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,12 +1046,15 @@ export default class IdsDropdown extends Base {
selector = `ids-list-box-option[value=""]:not([group-label]), ids-list-box-option:not([value]):not([group-label])`;
}

const listBoxOption = [...this.dropdownList?.listBox?.querySelectorAll<IdsListBoxOption>(selector) ?? []].at(0);
if (!listBoxOption) {
if (value) this.setAttribute(attributes.VALUE, String(value));
return;
}

// NOTE: setAttribute() must be called here, before the internal input.value is set below
this.setAttribute(attributes.VALUE, String(value));

const listBoxOption = [...this.dropdownList?.listBox?.querySelectorAll<IdsListBoxOption>(selector) ?? []].at(0);
if (!listBoxOption) return;

this.clearSelected();
this.selectOption(listBoxOption);
this.selectIcon(listBoxOption);
Expand Down
Loading

0 comments on commit f7caec2

Please sign in to comment.