From a20aa489929f0a04e0239528afa24648e799b83c Mon Sep 17 00:00:00 2001 From: Konnor Rogers Date: Tue, 29 Apr 2025 12:33:03 -0400 Subject: [PATCH] fix select (#892) * fix select * prettier --- src/components/select/select.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/select/select.ts b/src/components/select/select.ts index e2935fb37..648ff52a4 100644 --- a/src/components/select/select.ts +++ b/src/components/select/select.ts @@ -173,11 +173,12 @@ export default class WaSelect extends WebAwesomeFormAssociatedElement { this._value = val; let newValue = this.value; - if (newValue != oldValue) { + if (newValue !== oldValue) { this.requestUpdate('value', oldValue); } } } + get value() { let value = this._value ?? this.defaultValue; value = Array.isArray(value) ? value : [value]; @@ -678,6 +679,7 @@ export default class WaSelect extends WebAwesomeFormAssociatedElement { // Toggle values present in the DOM from this.value, while preserving options NOT present in the DOM (for lazy loading) // Note that options NOT present in the DOM will be moved to the end after this if (selectedValues.size > 0 || this._value) { + const oldValue = this._value; if (!this._value) { // First time it's set let value = this.defaultValue ?? []; @@ -687,6 +689,7 @@ export default class WaSelect extends WebAwesomeFormAssociatedElement { // Filter out values that are in the DOM this._value = this._value.filter(value => !this.optionValues?.has(value)); this._value.unshift(...selectedValues); + this.requestUpdate('value', oldValue); } // Update the value and display label