diff --git a/src/runtime/components/Textarea.vue b/src/runtime/components/Textarea.vue index c55b40e8..7511a91e 100644 --- a/src/runtime/components/Textarea.vue +++ b/src/runtime/components/Textarea.vue @@ -63,11 +63,11 @@ const ui = computed(() => tv({ extend: textarea, slots: props.ui })({ size: size?.value })) -const inputRef = ref(null) +const textareaRef = ref(null) function autoFocus () { if (props.autofocus) { - inputRef.value?.focus() + textareaRef.value?.focus() } } @@ -120,22 +120,22 @@ onMounted(() => { function autoResize () { if (props.autoresize) { - if (!inputRef.value) { + if (!textareaRef.value) { return } - inputRef.value.rows = props.rows + textareaRef.value.rows = props.rows - const styles = window.getComputedStyle(inputRef.value) + const styles = window.getComputedStyle(textareaRef.value) const paddingTop = parseInt(styles.paddingTop) const paddingBottom = parseInt(styles.paddingBottom) const padding = paddingTop + paddingBottom const lineHeight = parseInt(styles.lineHeight) - const { scrollHeight } = inputRef.value + const { scrollHeight } = textareaRef.value const newRows = (scrollHeight - padding) / lineHeight if (newRows > props.rows) { - inputRef.value.rows = props.maxrows ? Math.min(newRows, props.maxrows) : newRows + textareaRef.value.rows = props.maxrows ? Math.min(newRows, props.maxrows) : newRows } } } @@ -155,7 +155,7 @@ onMounted(() => {