@@ -83,6 +83,7 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
83
83
bot = root . bottom - vrect . top ,
84
84
left = hrect . left - root . left ,
85
85
width = hrect . width ,
86
+ offset = getVerticalOffset ( ) ,
86
87
styles = {
87
88
left : left + 'px' ,
88
89
minWidth : width + 'px' ,
@@ -93,14 +94,30 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
93
94
styles . bottom = bot + 'px' ;
94
95
styles . maxHeight = Math . min ( MAX_HEIGHT , hrect . top - root . top - MENU_PADDING ) + 'px' ;
95
96
} else {
96
- styles . top = top + 'px' ;
97
+ styles . top = ( top - offset ) + 'px' ;
97
98
styles . bottom = 'auto' ;
98
99
styles . maxHeight = Math . min ( MAX_HEIGHT , root . bottom - hrect . bottom - MENU_PADDING ) + 'px' ;
99
100
}
100
101
101
102
elements . $ . scrollContainer . css ( styles ) ;
102
103
$mdUtil . nextTick ( correctHorizontalAlignment , false ) ;
103
104
105
+ /**
106
+ * Calculates the vertical offset for floating label examples to account for ngMessages
107
+ * @returns {number }
108
+ */
109
+ function getVerticalOffset ( ) {
110
+ var offset = 0 ;
111
+ var inputContainer = $element . find ( 'md-input-container' ) ;
112
+ if ( inputContainer . length ) {
113
+ var input = inputContainer . find ( 'input' ) ;
114
+ offset = inputContainer . prop ( 'offsetHeight' ) ;
115
+ offset -= input . prop ( 'offsetTop' ) ;
116
+ offset -= input . prop ( 'offsetHeight' ) ;
117
+ }
118
+ return offset ;
119
+ }
120
+
104
121
/**
105
122
* Makes sure that the menu doesn't go off of the screen on either side.
106
123
*/
@@ -347,11 +364,12 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
347
364
}
348
365
}
349
366
367
+ /**
368
+ * Force blur on input element
369
+ * @param forceBlur
370
+ */
350
371
function doBlur ( forceBlur ) {
351
- if ( forceBlur ) {
352
- noBlur = false ;
353
- }
354
-
372
+ if ( forceBlur ) noBlur = false ;
355
373
elements . input . blur ( ) ;
356
374
}
357
375
0 commit comments