Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Nov 4, 2024
1 parent bb0e8e4 commit 2817c82
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/components/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,7 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon
* value attribute will be a space-delimited list of values based on the options selected, and the value property will
* be an array. **For this reason, values must not contain spaces.**
*/
@state({
// attribute: false,
// converter: {
// fromAttribute: (value: string) => value.split(' '),
// toAttribute: (value: string[]) => value.join(' ')
// }
})
@state()
set value(val: string | string[]) {
if (this.multiple) {
val = Array.isArray(val) ? val : val.split(' ');
Expand All @@ -131,7 +125,6 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon
}

this.valueHasChanged = true;

this._value = val;
}

Expand Down Expand Up @@ -618,7 +611,9 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon
// Update selected options cache
this.selectedOptions = options.filter(el => el.selected);

// Keep a reference to the previous `valueHasChanged`. Changes made here don't count has changing the value.
const cachedValueHasChanged = this.valueHasChanged;

// Update the value and display label
if (this.multiple) {
this.value = this.selectedOptions.map(el => el.value);
Expand Down Expand Up @@ -676,6 +671,8 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon
handleValueChange() {
if (!this.valueHasChanged) {
this.value = this.defaultValue;

// Set it back to false since this isn't an interaction.
this.valueHasChanged = false;
}

Expand Down

0 comments on commit 2817c82

Please sign in to comment.