Skip to content

Commit

Permalink
fix(textarea): autoresize reactivity (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarroufin authored Apr 28, 2022
1 parent 1bda2ec commit f0bfe20
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/runtime/components/forms/Textarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand All @@ -126,6 +130,10 @@ export default {
emit('update:modelValue', value)
}
watch(() => props.modelValue, () => {
nextTick(autoResize)
})
onMounted(() => {
setTimeout(() => {
autoFocus()
Expand Down

1 comment on commit f0bfe20

@vercel
Copy link

@vercel vercel bot commented on f0bfe20 Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui-nuxtlabs.vercel.app
nuxthq-ui.vercel.app
ui-git-dev-nuxtlabs.vercel.app

Please sign in to comment.