@@ -9,6 +9,10 @@ import inputProps from './inputProps';
99import PropTypes from '../_util/vue-types' ;
1010import { getOptionProps , getListeners } from '../_util/props-util' ;
1111
12+ const RESIZE_STATUS_NONE = 0 ;
13+ const RESIZE_STATUS_RESIZING = 1 ;
14+ const RESIZE_STATUS_RESIZED = 2 ;
15+
1216const TextAreaProps = {
1317 ...inputProps ,
1418 autosize : PropTypes . oneOfType ( [ Object , Boolean ] ) ,
@@ -20,7 +24,7 @@ const ResizableTextArea = {
2024 data ( ) {
2125 return {
2226 textareaStyles : { } ,
23- resizing : false ,
27+ resizeStatus : RESIZE_STATUS_NONE ,
2428 } ;
2529 } ,
2630 mixins : [ BaseMixin ] ,
@@ -39,6 +43,18 @@ const ResizableTextArea = {
3943 } ,
4044 } ,
4145 methods : {
46+ handleResize ( size ) {
47+ const { resizeStatus } = this . $data ;
48+ const { autoSize } = this . $props ;
49+
50+ if ( resizeStatus !== RESIZE_STATUS_NONE ) {
51+ return ;
52+ }
53+ this . $emit ( 'resize' , size ) ;
54+ if ( autoSize ) {
55+ this . resizeOnNextFrame ( ) ;
56+ }
57+ } ,
4258 resizeOnNextFrame ( ) {
4359 raf . cancel ( this . nextFrameActionId ) ;
4460 this . nextFrameActionId = raf ( this . resizeTextarea ) ;
@@ -51,11 +67,15 @@ const ResizableTextArea = {
5167 }
5268 const { minRows, maxRows } = autoSize ;
5369 const textareaStyles = calculateNodeHeight ( this . $refs . textArea , false , minRows , maxRows ) ;
54- this . setState ( { textareaStyles, resizing : true } , ( ) => {
70+ this . setState ( { textareaStyles, resizeStatus : RESIZE_STATUS_RESIZING } , ( ) => {
5571 raf . cancel ( this . resizeFrameId ) ;
5672 this . resizeFrameId = raf ( ( ) => {
57- this . setState ( { resizing : false } ) ;
58- this . fixFirefoxAutoScroll ( ) ;
73+ this . setState ( { resizeStatus : RESIZE_STATUS_RESIZED } , ( ) => {
74+ this . resizeFrameId = raf ( ( ) => {
75+ this . setState ( { resizeStatus : RESIZE_STATUS_NONE } ) ;
76+ this . fixFirefoxAutoScroll ( ) ;
77+ } ) ;
78+ } ) ;
5979 } ) ;
6080 } ) ;
6181 } ,
@@ -77,7 +97,7 @@ const ResizableTextArea = {
7797 renderTextArea ( ) {
7898 const props = getOptionProps ( this ) ;
7999 const { prefixCls, autoSize, autosize, disabled } = props ;
80- const { textareaStyles, resizing } = this . $data ;
100+ const { textareaStyles, resizeStatus } = this . $data ;
81101 warning (
82102 autosize === undefined ,
83103 'Input.TextArea' ,
@@ -104,7 +124,9 @@ const ResizableTextArea = {
104124 }
105125 const style = {
106126 ...textareaStyles ,
107- ...( resizing ? { overflowX : 'hidden' , overflowY : 'hidden' } : null ) ,
127+ ...( resizeStatus === RESIZE_STATUS_RESIZING
128+ ? { overflowX : 'hidden' , overflowY : 'hidden' }
129+ : null ) ,
108130 } ;
109131 const textareaProps = {
110132 attrs : otherProps ,
@@ -119,7 +141,7 @@ const ResizableTextArea = {
119141 ] ,
120142 } ;
121143 return (
122- < ResizeObserver onResize = { this . resizeOnNextFrame } disabled = { ! ( autoSize || autosize ) } >
144+ < ResizeObserver onResize = { this . handleResize } disabled = { ! ( autoSize || autosize ) } >
123145 < textarea { ...textareaProps } ref = "textArea" />
124146 </ ResizeObserver >
125147 ) ;
0 commit comments