-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
1 similar comment
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
@@ -207,6 +207,17 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming, | |||
elements.$ = getAngularElements(elements); | |||
} | |||
|
|||
/** | |||
* Finds the correct element that will determine the width |
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.
That's not a valid description. getWrapTarget
will be not used to only determine the width. As the function says, it's just scanning for the wrap
target.
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.
The warp
is used to calculate the width of the menu. I"ll update the description accordingly.
@aperl Thanks for the PR, but please provide more details in your Pull Request description. For example, what's the use-cases etc. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
@@ -208,6 +208,17 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming, | |||
} | |||
|
|||
/** | |||
* Find the target for the wrap element which determines menu width |
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'm still not happy with the function description. The wrap is not specializing on determining the menu width.
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 the name wrap
describes what the element is, as far as the controller is concerned it only uses the wrap to calculate the width which can be found in positionDropdown ()
. I could change the comment to something like "Find the target for the wrap element." But I thought more description help convey why this code is there. Again the description is similar to that of getSnapTarget()
. In the end I'll make the description to whatever would be satisfactory.
@devversion I've updated the initial comment to add use case and further description. I'll look now for the appropriate place to add this to documentation. |
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
I like the principle of this PR, but it definitely needs some tests. I am rerunning the Travis build to see if it passes existing tests; something threw off the original build. |
@topherfangio, what sort of test would we be looking for? |
Regarding tests; I think it could be relatively simple. Just test both cases:
|
* @returns {*} | ||
*/ | ||
function getWrapTarget() { | ||
for (var element = $element; element.length; element = element.parent()) { |
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'm wondering if there is a better way to accomplish this using a directive. Perhaps the md-autocomplete-wrap-override
could be a full directive that searches for child autocomplete's (perhaps using some combination of .querySelector()
and .controller()
) and register with them as the wrapper so that we don't have to traverse the entire tree of parents all the way back up the DOM.
@aperl You think you could give this a shot?
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.
@topherfangio It wouldn't be that hard. I"ll hop on it.
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.
@topherfangio So the md-autocomplete-wrap-override
seemed like an easy way to do it but then it got fragile when I looked at a situation where the md-autocomplete
element resided inside and ng-if
. In this case the md-autocomplete-wrap-override
can't find the md-autocomplete
controller to register to.
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 suspect it is for similar reasons md-autocomplete-snap
is found by walking up the DOM.
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.
Hmm, good point; okay, let me think about it a bit more. Please ping me early next week if I forget to respond though 😄
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.
Another way to go would be to piggy back on the md-autocomplete-snap
attribute and give it an optional value md-autocomplete-snap="width"
. This would avoid adding another attribute and then we could only have to walk up the DOM once.
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.
That's not a bad idea; although I am a bit confused as to how this doesn't already affect the width of the item. Are positioning and width somehow separate?
(I didn't actually know md-autocomplete-snap
existed since it's not in the docs)
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.
For whatever reason the md-autocomplete-snap
was only made to effect the vertical position.
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.
Okay, if it's relatively easy to do; why don't you go ahead with the md-autocomplete-snap="width"
approach. That will give us the most flexibility.
If you can also add some docs to the Autocomplete about it's usage, that would be great!
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'll update the PR
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
@topherfangio where would I go to add documentation about |
@aperl I would just add it to the existing autocomplete docs. They can be found at the top of |
@topherfangio the documentation changes are in. |
@topherfangio the conflicts were simple. The PR has been rebased. |
@aperl Thanks so much for the super-fast turn around! |
@topherfangio is there anything else I need to do? |
@aperl Nope. It's labelled as presubmit, so it will go through Google's presubmit process where they run it against internal tests. If all the tests pass, then it should get immediately merged. If they fail, we should get some more info on the PR with the failure so we can investigate. If it happens to break a TON of tests, it's possible that it may get rejected (with a note), but since this is a small addition/non-breaking change, I wouldn't expect that. |
@topherfangio thanks for the info |
@aperl can you rebase? |
7891060
to
741df73
Compare
@jelbourn Rebase done. |
This seems to work very well like this:
But without both the
Would be nice to have this in a release indeed :) |
@barryvdh md-autocomplete-snap was already a feature, though perhaps not well documented. It would cause the dropdown to snap the the specified element. For reverse compatibly it was decided to add the |
This allows a
md-autocomplete-wrap
to be applied to an ancestor of amd-autocomplete
and cause that element to be used for evaluating the width of the autocomplete instead of the themd-autocomplete-wrap
element. This addresses #4450 which constrains the width of the menu that pops up to the width of the auto complete wrapper.When using chips and possibly in other situations it would be desirable to have the menu be the width of the chips component.
Adding support for this attribute would allow for this and other similar behavior.
A working version of this change can be seen at https://codepen.io/allenperl/pen/KzmQwr.