@@ -88,11 +88,13 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
88
88
}
89
89
90
90
/**
91
- * Position the items outer container Below or Above the input
91
+ * Position the items outer container so selected item text is positioned over input text and if header
92
+ * And/OR footer - both header/footer are visible
92
93
* @param selectFit selectFit to use for computation.
93
94
*/
94
95
protected fitInViewport ( contentElement : HTMLElement , selectFit : SelectFit ) {
95
-
96
+ const footer = selectFit . scrollContainer . getBoundingClientRect ( ) . bottom - selectFit . contentElementRect . bottom ;
97
+ const lastItemFitSize = selectFit . targetRect . bottom + selectFit . styles . itemTextToInputTextDiff - footer ;
96
98
// out of viewPort on Top
97
99
if ( selectFit . fitVertical . back < 0 ) {
98
100
const possibleScrollAmount = selectFit . scrollContainer . scrollHeight -
@@ -107,17 +109,22 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
107
109
}
108
110
// out of viewPort on Bottom
109
111
} else if ( selectFit . fitVertical . forward < 0 ) {
110
- if ( selectFit . scrollAmount + selectFit . fitVertical . forward > 0 ) {
112
+ if ( lastItemFitSize > selectFit . viewPortRect . bottom ) {
113
+ this . positionAbove ( selectFit ) ;
114
+ } else if ( selectFit . scrollAmount + selectFit . fitVertical . forward > 0 ) {
111
115
selectFit . scrollAmount += selectFit . fitVertical . forward ;
112
116
selectFit . verticalOffset += selectFit . fitVertical . forward ;
113
117
this . global_yOffset = selectFit . verticalOffset ;
114
118
} else {
115
- selectFit . verticalOffset = - selectFit . contentElementRect . height + selectFit . targetRect . height ;
116
- this . global_yOffset = selectFit . verticalOffset ;
119
+ this . positionAbove ( selectFit ) ;
117
120
}
118
121
}
119
122
}
120
123
124
+ private positionAbove ( selectFit : SelectFit ) {
125
+ selectFit . verticalOffset = - selectFit . contentElementRect . height + selectFit . targetRect . height ;
126
+ this . global_yOffset = selectFit . verticalOffset ;
127
+ }
121
128
122
129
/**
123
130
* Sets element's style which effectively positions the provided element
0 commit comments