Skip to content

Commit 262f54a

Browse files
committed
fix(textarea): modelvalue null value
1 parent d9b62fe commit 262f54a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/blue-apes-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@indielayer/ui": patch
3+
---
4+
5+
fix(textarea): modelvalue null value

packages/ui/src/components/textarea/Textarea.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ const currentLength = computed(() => {
119119
120120
const showClearIcon = computed(() => props.clearable && props.modelValue !== '')
121121
122+
function isEmpty(value: typeof props.modelValue) {
123+
if (typeof value === 'undefined' || value === null) return true
124+
125+
return false
126+
}
127+
122128
const { styles, classes, className } = useTheme('Textarea', {}, props, { errorInternal })
123129
124130
defineExpose({ focus, blur, reset, validate, setError })
@@ -161,7 +167,7 @@ defineExpose({ focus, blur, reset, validate, setError })
161167
:name="name"
162168
:placeholder="placeholder"
163169
:readonly="readonly"
164-
:value="typeof modelValue !== 'undefined' ? String(modelValue) : ''"
170+
:value="isEmpty(modelValue) ? '' : String(modelValue)"
165171
v-bind="dataAttrs"
166172
v-on="inputListeners"
167173
@keydown.enter="onEnter"

0 commit comments

Comments
 (0)