Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
KonnorRogers committed Oct 2, 2024
1 parent 8368943 commit 3b79fa9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/pages/components/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ Here are the following conditions:

EX: `<wa-select value="foo">` will have a value of `""` until `<wa-option value="foo">Foo</wa-option>` connects, at which point its value will become `"foo"` when submitting.

- If a `<wa-select multiple>` with an initial value has multiple values, but only some of the options are present, it will only respect the options that are present, and if a selected option is loaded in later, *AND* the value of the select has not changed via user interaction or direct property assignment, it will add the selected option to the form value and to the `.value` of the select.
- If a `<wa-select multiple>` with an initial value has multiple values, but only some of the options are present, it will only respect the options that are present, and if a selected option is loaded in later, _AND_ the value of the select has not changed via user interaction or direct property assignment, it will add the selected option to the form value and to the `.value` of the select.

This can be hard to conceptualize, so heres a fairly large example showing how lazy loaded options work with `<wa-select>` and `<wa-select multiple>` when given initial value attributes. Feel free to play around with it in a codepen.

Expand Down Expand Up @@ -607,4 +607,4 @@ This can be hard to conceptualize, so heres a fairly large example showing how l

:::warning
Be sure you trust the content you are outputting! Passing unsanitized user input to `getTag()` can result in XSS vulnerabilities.
:::
:::
12 changes: 6 additions & 6 deletions src/components/select/select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon
@state() displayLabel = '';
@state() currentOption: SlOption;
@state() selectedOptions: SlOption[] = [];
@state() private valueHasChanged: boolean = false
@state() private valueHasChanged: boolean = false;

/** The name of the select, submitted as a name/value pair with form data. */
@property() name = '';


private _defaultValue: string | string[] = '';

@property({
Expand Down Expand Up @@ -240,8 +239,8 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon
super.connectedCallback();

setTimeout(() => {
this.handleDefaultSlotChange()
})
this.handleDefaultSlotChange();
});

// Because this is a form control, it shouldn't be opened initially
this.open = false;
Expand Down Expand Up @@ -337,7 +336,7 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon

// If it is open, update the value based on the current selection and close it
if (this.currentOption && !this.currentOption.disabled) {
this.valueHasChanged = true
this.valueHasChanged = true;
if (this.multiple) {
this.toggleOptionSelection(this.currentOption);
} else {
Expand Down Expand Up @@ -632,7 +631,8 @@ export default class SlSelect extends ShoelaceElement implements ShoelaceFormCon
} else {
const selectedOption = this.selectedOptions[0];
this.value = selectedOption?.value ?? '';
this.displayLabel = selectedOption?.getTextLabel?.() ?? '';}
this.displayLabel = selectedOption?.getTextLabel?.() ?? '';
}

// Update validity
this.updateComplete.then(() => {
Expand Down

0 comments on commit 3b79fa9

Please sign in to comment.