Skip to content

Commit

Permalink
Prevents error if sl-input has value undefined (#513)
Browse files Browse the repository at this point in the history
The sl-input's value state being `undefined` is very common when using shoelace with frameworks. Instead of erroring out and not showing the input, this should handle it gracefully.
  • Loading branch information
sidharthramesh committed Aug 30, 2021
1 parent 147a8d2 commit da3415d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export default class SlInput extends LitElement {
'input--pill': this.pill,
'input--disabled': this.disabled,
'input--focused': this.hasFocus,
'input--empty': this.value.length === 0,
'input--empty': this.value?.length === 0,
'input--invalid': this.invalid
})}
>
Expand Down Expand Up @@ -344,7 +344,7 @@ export default class SlInput extends LitElement {
@blur=${this.handleBlur}
/>
${this.clearable && this.value.length > 0
${this.clearable && this.value?.length > 0
? html`
<button
part="clear-button"
Expand Down

0 comments on commit da3415d

Please sign in to comment.