@@ -99,8 +99,6 @@ class Autocomplete extends React.Component<
9999 ) ;
100100 }
101101 }
102-
103- this . _calculatePosition ( ) ;
104102 }
105103
106104 _calculatePosition = ( ) => {
@@ -142,6 +140,12 @@ class Autocomplete extends React.Component<
142140 ? POSITION_CONFIGURATION . Y . BOTTOM
143141 : POSITION_CONFIGURATION . Y . TOP ;
144142
143+ if (
144+ this . state . dropdownHeight === dropdownHeight &&
145+ this . state . dropdownWidth === dropdownWidth
146+ )
147+ return ;
148+
145149 this . setState ( {
146150 xConfig,
147151 yConfig,
@@ -150,6 +154,10 @@ class Autocomplete extends React.Component<
150154 } ) ;
151155 } ;
152156
157+ componentDidUpdate ( ) {
158+ this . _calculatePosition ( ) ;
159+ }
160+
153161 render ( ) {
154162 const { style, className, innerRef, children, top, left } = this . props ;
155163 const { xConfig, yConfig, dropdownHeight, dropdownWidth } = this . state ;
@@ -202,8 +210,6 @@ class ReactTextareaAutocomplete extends React.Component<
202210 constructor ( props : TextareaProps ) {
203211 super ( props ) ;
204212
205- Listeners . add ( KEY_CODES . ESC , ( ) => this . _closeAutocomplete ( ) ) ;
206-
207213 const { loadingComponent , trigger, value } = this . props ;
208214
209215 if ( value ) this . state . value = value ;
@@ -233,6 +239,7 @@ class ReactTextareaAutocomplete extends React.Component<
233239 } ;
234240
235241 componentDidMount ( ) {
242+ Listeners . add ( KEY_CODES . ESC , this . _closeAutocomplete ) ;
236243 Listeners . startListen ( ) ;
237244 }
238245
0 commit comments