@@ -86,52 +86,74 @@ class Autocomplete extends React.Component<AutocompleteProps> {
86
86
}
87
87
88
88
componentDidUpdate ( ) {
89
- const top = this . props . top || 0
90
- const left = this . props . left || 0
91
- const usedClasses = [ ]
92
- const unusedClasses = [ ]
89
+ const top = this . props . top || 0 ;
90
+ const left = this . props . left || 0 ;
91
+ const usedClasses = [ ] ;
92
+ const unusedClasses = [ ] ;
93
93
94
- let topPosition = 0
95
- let leftPosition = 0
94
+ let topPosition = 0 ;
95
+ let leftPosition = 0 ;
96
96
97
- const containerBounds = this . containerElem . getBoundingClientRect ( )
98
- const dropdownBounds = this . ref . getBoundingClientRect ( )
99
- const textareaBounds = this . props . textareaRef . getBoundingClientRect ( )
97
+ const containerBounds = this . containerElem . getBoundingClientRect ( ) ;
98
+ const dropdownBounds = this . ref . getBoundingClientRect ( ) ;
99
+ const textareaBounds = this . props . textareaRef . getBoundingClientRect ( ) ;
100
100
const computedStyle = window . getComputedStyle ( this . ref ) ;
101
101
102
- const marginTop = parseInt ( computedStyle . getPropertyValue ( 'margin-top' ) , 10 )
103
- const marginBottom = parseInt ( computedStyle . getPropertyValue ( 'margin-bottom' ) , 10 )
104
- const marginLeft = parseInt ( computedStyle . getPropertyValue ( 'margin-left' ) , 10 )
105
- const marginRight = parseInt ( computedStyle . getPropertyValue ( 'margin-right' ) , 10 )
102
+ const marginTop = parseInt (
103
+ computedStyle . getPropertyValue ( "margin-top" ) ,
104
+ 10
105
+ ) ;
106
+ const marginBottom = parseInt (
107
+ computedStyle . getPropertyValue ( "margin-bottom" ) ,
108
+ 10
109
+ ) ;
110
+ const marginLeft = parseInt (
111
+ computedStyle . getPropertyValue ( "margin-left" ) ,
112
+ 10
113
+ ) ;
114
+ const marginRight = parseInt (
115
+ computedStyle . getPropertyValue ( "margin-right" ) ,
116
+ 10
117
+ ) ;
106
118
107
- const dropdownBottom = marginTop + marginBottom + textareaBounds . top + top + dropdownBounds . height
108
- const dropdownRight = marginLeft + marginRight + textareaBounds . left + left + dropdownBounds . width
119
+ const dropdownBottom =
120
+ marginTop +
121
+ marginBottom +
122
+ textareaBounds . top +
123
+ top +
124
+ dropdownBounds . height ;
125
+ const dropdownRight =
126
+ marginLeft +
127
+ marginRight +
128
+ textareaBounds . left +
129
+ left +
130
+ dropdownBounds . width ;
109
131
110
132
if ( dropdownRight > containerBounds . right ) {
111
- leftPosition = left - dropdownBounds . width
112
- usedClasses . push ( POSITION_CONFIGURATION . X . LEFT )
113
- unusedClasses . push ( POSITION_CONFIGURATION . X . RIGHT )
133
+ leftPosition = left - dropdownBounds . width ;
134
+ usedClasses . push ( POSITION_CONFIGURATION . X . LEFT ) ;
135
+ unusedClasses . push ( POSITION_CONFIGURATION . X . RIGHT ) ;
114
136
} else {
115
- leftPosition = left
116
- usedClasses . push ( POSITION_CONFIGURATION . X . RIGHT )
117
- unusedClasses . push ( POSITION_CONFIGURATION . X . LEFT )
137
+ leftPosition = left ;
138
+ usedClasses . push ( POSITION_CONFIGURATION . X . RIGHT ) ;
139
+ unusedClasses . push ( POSITION_CONFIGURATION . X . LEFT ) ;
118
140
}
119
141
120
142
if ( dropdownBottom > containerBounds . bottom ) {
121
- topPosition = top - dropdownBounds . height
122
- usedClasses . push ( POSITION_CONFIGURATION . Y . TOP )
123
- unusedClasses . push ( POSITION_CONFIGURATION . Y . BOTTOM )
143
+ topPosition = top - dropdownBounds . height ;
144
+ usedClasses . push ( POSITION_CONFIGURATION . Y . TOP ) ;
145
+ unusedClasses . push ( POSITION_CONFIGURATION . Y . BOTTOM ) ;
124
146
} else {
125
- topPosition = top
126
- usedClasses . push ( POSITION_CONFIGURATION . Y . BOTTOM )
127
- unusedClasses . push ( POSITION_CONFIGURATION . Y . TOP )
147
+ topPosition = top ;
148
+ usedClasses . push ( POSITION_CONFIGURATION . Y . BOTTOM ) ;
149
+ unusedClasses . push ( POSITION_CONFIGURATION . Y . TOP ) ;
128
150
}
129
151
130
- this . ref . style . top = `${ topPosition } px`
131
- this . ref . style . left = `${ leftPosition } px`
152
+ this . ref . style . top = `${ topPosition } px` ;
153
+ this . ref . style . left = `${ leftPosition } px` ;
132
154
133
- this . ref . classList . remove ( ...unusedClasses )
134
- this . ref . classList . add ( ...usedClasses )
155
+ this . ref . classList . remove ( ...unusedClasses ) ;
156
+ this . ref . classList . add ( ...usedClasses ) ;
135
157
}
136
158
137
159
render ( ) {
0 commit comments