Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 8d965aa

Browse files
marosoftmmalerba
authored andcommitted
fix(autocomplete): show dropdown on top only when there is room (#11575)
Don't use the bounding rectangles of a document body to determine the position of the dropdown. Top and bottom values of the snap element are relative to the viewport, which is enough to decide about the position of the dropdown. Fixes #10859
1 parent 532d0d0 commit 8d965aa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/components/autocomplete/js/autocompleteController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
140140

141141
// Automatically determine dropdown placement based on available space in viewport.
142142
if (!position) {
143-
position = (top > bot && root.height - top - MENU_PADDING < dropdownHeight) ? 'top' : 'bottom';
143+
position = (vrect.top + MENU_PADDING > dropdownHeight) ? 'top' : 'bottom';
144144
}
145145
// Adjust the width to account for the padding provided by `md-input-container`
146146
if ($attrs.mdFloatingLabel) {

0 commit comments

Comments
 (0)