From 6adca7eed1d89b235b9fee61a4186dc3f4052e8f Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Thu, 27 Aug 2020 12:23:24 -0400 Subject: [PATCH] Fixed value = null error; closes #187 --- CHANGELOG.md | 1 + src/components/input/input.tsx | 2 +- src/components/select/select.tsx | 2 +- src/components/textarea/textarea.tsx | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9966e4cf..748d0e49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed a bug where clicking a tag in `sl-select` wouldn't toggle the menu - Fixed a bug where options where `sl-select` options weren't always visible or scrollable +- Fixed a bug where setting `null` on `sl-input`, `sl-textarea`, or `sl-select` would throw an error ## 2.0.0-beta.16 diff --git a/src/components/input/input.tsx b/src/components/input/input.tsx index ac1a1191..da58a44d 100644 --- a/src/components/input/input.tsx +++ b/src/components/input/input.tsx @@ -264,7 +264,7 @@ export class Input { '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--valid': this.valid, 'input--invalid': this.invalid }} diff --git a/src/components/select/select.tsx b/src/components/select/select.tsx index 0ee12784..009f7e06 100644 --- a/src/components/select/select.tsx +++ b/src/components/select/select.tsx @@ -361,7 +361,7 @@ export class Select { class={{ select: true, 'select--open': this.isOpen, - 'select--empty': this.value.length === 0, + 'select--empty': this.value?.length === 0, 'select--focused': this.hasFocus, 'select--disabled': this.disabled, 'select--multiple': this.multiple, diff --git a/src/components/textarea/textarea.tsx b/src/components/textarea/textarea.tsx index 6f1eacfb..7d72b299 100644 --- a/src/components/textarea/textarea.tsx +++ b/src/components/textarea/textarea.tsx @@ -224,7 +224,7 @@ export class Textarea { // States 'textarea--disabled': this.disabled, 'textarea--focused': this.hasFocus, - 'textarea--empty': this.value.length === 0, + 'textarea--empty': this.value?.length === 0, 'textarea--valid': this.valid, 'textarea--invalid': this.invalid,