fix(textarea): autoresize reactivity (#52)

This commit is contained in:
Sylvain Marroufin
2022-04-28 11:39:03 +02:00
committed by GitHub
parent 1bda2ec01f
commit f0bfe20572

View File

@@ -19,7 +19,7 @@
</template>
<script>
import { ref, computed, onMounted } from 'vue'
import { ref, computed, watch, onMounted, nextTick } from 'vue'
import { classNames } from '../../utils'
import $ui from '#build/ui'
@@ -104,6 +104,10 @@ export default {
const autoResize = () => {
if (props.autoresize) {
if (!textarea.value) {
return
}
textarea.value.rows = props.rows
const styles = window.getComputedStyle(textarea.value)
@@ -126,6 +130,10 @@ export default {
emit('update:modelValue', value)
}
watch(() => props.modelValue, () => {
nextTick(autoResize)
})
onMounted(() => {
setTimeout(() => {
autoFocus()