2222 @focus =" onFocus"
2323 @blur =" onBlur"
2424 @paste =" onPaste"
25+ @autosize-updated =" updateShowIsInputTextareaExpandButtonVisibility"
2526 />
2627 <div :class =" $style.over" />
2728 <dropdown-suggester
@@ -78,6 +79,7 @@ const emit = defineEmits<{
7879 (e : ' postMessage' ): void
7980 (e : ' modifierKeyDown' ): void
8081 (e : ' modifierKeyUp' ): void
82+ (e : ' autosize-updated' ): void
8183}>()
8284
8385const firefoxFlag = isFirefox ()
@@ -143,16 +145,19 @@ const onBlur = () => {
143145 emit (' blur' )
144146}
145147
148+ const textAreaAutoSizeMaxHeightShrunk = computed (() =>
149+ isMobile .value ? 70 : 160
150+ )
151+
146152const textAreaAutoSizeMaxHeight = computed (() => {
147153 if (props .isMaxHeightNone ) {
148154 return ' none'
149155 }
150-
151- if (isMobile .value ) {
152- return props .isInputTextAreaExpanded ? ' 140px' : ' 70px'
153- } else {
154- return props .isInputTextAreaExpanded ? ' 320px' : ' 160px'
155- }
156+ return (
157+ (props .isInputTextAreaExpanded
158+ ? textAreaAutoSizeMaxHeightShrunk .value * 2
159+ : textAreaAutoSizeMaxHeightShrunk .value ) + ' px'
160+ )
156161})
157162
158163const scollbarWidth = getScrollbarWidth ()
@@ -168,24 +173,18 @@ const showIsInputTextAreaExpandedButton = defineModel<boolean>(
168173 }
169174)
170175
171- const updateTextareaExpandButtonVisibility = () => {
172- if (textareaRef .value ) {
173- const height = textareaRef .value .scrollHeight
174- if (isMobile .value ) {
175- showIsInputTextAreaExpandedButton .value = height >= 70
176- } else {
177- showIsInputTextAreaExpandedButton .value = height >= 160
176+ const updateShowIsInputTextareaExpandButtonVisibility = () => {
177+ nextTick (() => {
178+ if (textareaRef .value ) {
179+ showIsInputTextAreaExpandedButton .value =
180+ textareaRef .value .scrollHeight > textAreaAutoSizeMaxHeightShrunk .value
178181 }
179- }
182+ })
180183}
181184
182185watch (
183- value ,
184- () => {
185- nextTick (() => {
186- updateTextareaExpandButtonVisibility ()
187- })
188- },
186+ [value ],
187+ updateShowIsInputTextareaExpandButtonVisibility ,
189188 { immediate: true }
190189)
191190 </script >
0 commit comments