Skip to content

Commit 6894546

Browse files
committed
update value in combobox-list when value in combobox is set
1 parent 1bbece2 commit 6894546

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

packages/uui-combobox/lib/uui-combobox.element.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ export class UUIComboboxElement extends FormControlMixin(LitElement) {
7676
`,
7777
];
7878

79+
get value() {
80+
return this._value;
81+
}
82+
set value(newValue) {
83+
super.value = newValue;
84+
85+
if (typeof newValue === 'string') {
86+
this._updateValue(newValue);
87+
}
88+
}
89+
7990
/**
8091
* The search input.
8192
* @type { string }
@@ -151,12 +162,18 @@ export class UUIComboboxElement extends FormControlMixin(LitElement) {
151162

152163
if (typeof this.value === 'string') {
153164
await this.updateComplete;
154-
this._comboboxList.value = this.value;
155-
this._displayValue = this._comboboxList?.displayValue || '';
165+
this._updateValue(this.value);
156166
}
157167
}
158168
}
159169

170+
private _updateValue(value: string) {
171+
if (this._comboboxList) {
172+
this._comboboxList.value = value;
173+
this._displayValue = this._comboboxList?.displayValue || '';
174+
}
175+
}
176+
160177
protected getFormElement(): HTMLElement | undefined {
161178
return this._input;
162179
}

0 commit comments

Comments
 (0)