Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(useTextareaAutosize): support changes of element width (#2541)
  • Loading branch information
dpschen committed Dec 16, 2022
1 parent 8bb7b50 commit ebd4852
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/core/useTextareaAutosize/index.ts
@@ -1,6 +1,7 @@
import type { MaybeRef } from '@vueuse/shared'
import type { WatchSource } from 'vue-demi'
import { ref, watch } from 'vue-demi'
import useResizeObserver from '../useResizeObserver'

export interface UseTextareaAutosizeOptions {
/** Textarea element to autosize. */
Expand Down Expand Up @@ -29,6 +30,8 @@ export function useTextareaAutosize(options?: UseTextareaAutosizeOptions) {

watch([input, textarea], triggerResize, { immediate: true })

useResizeObserver(textarea, () => triggerResize())

if (options?.watch)
watch(options.watch, triggerResize, { immediate: true, deep: true })

Expand Down

0 comments on commit ebd4852

Please sign in to comment.