Skip to content

Commit

Permalink
fix(ui5-select): correct "value" setter to operate on the light DOM (#…
Browse files Browse the repository at this point in the history
…8067)

:вя
  • Loading branch information
ilhan007 committed Jan 11, 2024
1 parent cddf8ba commit 4567d8a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/main/src/Select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ class Select extends UI5Element implements IFormElement {
this._onMenuChange = this.onMenuChange.bind(this);
this._attachMenuListeners = this.attachMenuListeners.bind(this);
this._detachMenuListeners = this.detachMenuListeners.bind(this);

this._upgradeProperty("value");
}

onBeforeRendering() {
Expand Down Expand Up @@ -540,8 +542,11 @@ class Select extends UI5Element implements IFormElement {
* @formEvents change liveChange
*/
set value(newValue: string) {
this.selectOptions.forEach(option => {
option.selected = !!((option.value || option.textContent) === newValue);
const menu = this._getSelectMenu();
const selectOptions = Array.from(menu ? menu.children : this.children).filter(option => !option.getAttribute("disabled")) as Array<IOption>;

selectOptions.forEach(option => {
option.selected = !!((option.getAttribute("value") || option.textContent) === newValue);
});
}

Expand Down

0 comments on commit 4567d8a

Please sign in to comment.