@@ -258,7 +258,11 @@ uis.directive('uiSelect',
258
258
259
259
// Support changing the direction of the dropdown if there isn't enough space to render it.
260
260
scope . $watch ( '$select.open' , function ( isOpen ) {
261
- if ( isOpen ) {
261
+ scope . calculateDropdownPos ( ) ;
262
+ } ) ;
263
+
264
+ scope . calculateDropdownPos = function ( ) {
265
+ if ( $select . open ) {
262
266
dropdown = angular . element ( element ) . querySelectorAll ( '.ui-select-dropdown' ) ;
263
267
if ( dropdown === null ) {
264
268
return ;
@@ -269,6 +273,9 @@ uis.directive('uiSelect',
269
273
270
274
// Delay positioning the dropdown until all choices have been added so its height is correct.
271
275
$timeout ( function ( ) {
276
+
277
+ element . removeClass ( directionUpClassName ) ;
278
+
272
279
var offset = uisOffset ( element ) ;
273
280
var offsetDropdown = uisOffset ( dropdown ) ;
274
281
@@ -277,9 +284,14 @@ uis.directive('uiSelect',
277
284
278
285
// Determine if the direction of the dropdown needs to be changed.
279
286
if ( offset . top + offset . height + offsetDropdown . height > scrollTop + $document [ 0 ] . documentElement . clientHeight ) {
287
+ //Go UP
280
288
dropdown [ 0 ] . style . position = 'absolute' ;
281
289
dropdown [ 0 ] . style . top = ( offsetDropdown . height * - 1 ) + 'px' ;
282
290
element . addClass ( directionUpClassName ) ;
291
+ } else {
292
+ //Go DOWN
293
+ dropdown [ 0 ] . style . position = '' ;
294
+ dropdown [ 0 ] . style . top = '' ;
283
295
}
284
296
285
297
// Display the dropdown once it has been positioned.
@@ -295,7 +307,7 @@ uis.directive('uiSelect',
295
307
dropdown [ 0 ] . style . top = '' ;
296
308
element . removeClass ( directionUpClassName ) ;
297
309
}
298
- } ) ;
310
+ } ;
299
311
} ;
300
312
}
301
313
} ;
0 commit comments