-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add md-dropdown-position option to mdAutocomplete. #9774
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
Having unit tests for this attribute would be good (Just checking for the
top
orbottom
attribute, to detect the alignment)
@@ -106,7 +106,12 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming, | |||
left = hrect.left - root.left, | |||
width = hrect.width, | |||
offset = getVerticalOffset(), | |||
position = $attrs.mdDropdownPosition, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use $scope.dropdownPosition
to support values which can change during runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, so should this be a text binding or two-way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think text binding would make more sense here (mdDropdownPosition: '@?'
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
styles; | ||
// Automatically determine dropdown placement based on available space in viewport. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you are at it, can you add an empty line before the comment (just looks better then)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
I am having trouble running the tests — is there documentation somewhere on that? I couldn't find anything in https://github.com/angular/material/blob/master/.github/CONTRIBUTING.md. When running
I have at least two versions of Chrome installed. ;) |
I'm sorry, yeah we have not included the chrome karma launcher right now (accidentally) but it will be fixed soon. Try doing |
Thanks — I've added a test case now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Please fix those two minor comments, then this should be ready.
'md-items="item in match(searchText)" ' + | ||
'md-item-text="item" ' + | ||
'md-min-length="0" ' + | ||
'md-dropdown-position="' + dropdownPosition +'"' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just create a scope variable for this, so you can just update the variable later?
<x md-dropdown-position="{{ position }}">
// Then later you could just do the following
scope.$apply('position = "bottom"');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
expect(scrollContainer.style.top).toMatch(/[0-9]+px/); | ||
expect(scrollContainer.style.bottom).toBe('auto'); | ||
|
||
document.body.removeChild(parent[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to
parent.remove();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
@donmccurdy Just looked again on this and it LGTM. Can you please rebase the PR if possible? |
@donmccurdy - after rebase, lgtm. |
Because obstructions in the viewport (liked fixed-position elements) cannot be automatically detected, allow users to override top/bottom positioning when needed. Usage: ```html <md-autocomplete md-items="item in ctrl.querySearch(ctrl.searchText)" md-dropdown-position="bottom" ... ``` Fixes #9769.
@devversion @ThomasBurleson Thanks! I've rebased against master. The Travis CI build stalled, though, is that likely to be related to my code? |
Because obstructions in the viewport (liked fixed-position elements) cannot be automatically detected, allow users to override top/bottom positioning when needed.
Usage:
Fixes #9769.