autocompletes overlay position works wrong on mobile devices
Bug, feature request, or proposal:
Bug
What is the expected behavior?
Correct overlay position so that the component can be used on mobile devices
What is the current behavior?
On mobile devices (e.g iphone6+ with latest IOS, Android etc.) the position of the overlay is strange. Sometimes the overlay disappears or the overlay overlaps the input fields ...
So autocomplete is NOT usable on mobile devices....
What are the steps to reproduce?
E.g. use the https://material.angular.io/ demo for autocomplete on mobile devices
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 4.3.3, Material 2.0.0-beta.8
Is there anything else we should know?
The positioning of the autocomplete just changed to be more accurately connected to the input. Here is an example with the latest build: http://plnkr.co/edit/HnQwfr7WlNVLdP3P6ukQ?p=preview
However, I am still seeing some weird positioning in landscape mode with the keyboard open:
The issue is that the keyboard animation throws off the positioning logic. I've been considering whether having a setTimeout on focus for iOS and Android would make sense @jelbourn?
@crisbeto that seems reasonable if we scope the delay to only apply for these cases. Let's address this after the overlay positioning refactor
@crisbeto is there any timeframe until func is getting better on IOS -> Otherwise I have to consider to replace autocomplete temporarly...
The initial plan was to address this after we refactor some of our positioning logic, but I suppose that shouldn't really change what we do in the autocomplete. There should be a way for you to patch it on your side temporarily, but it'll be very hacky, because it would need to access private properties on the autocomplete trigger.
@crisbeto what is the way to "patch" autocomplete so that it work better on IOS???
I've been playing around with the approach I mentioned above, but it doesn't really work the way I expected it to. It seems like the autocomplete does figure out the proper position values, however iOS throws it off when it scrolls the input into the middle of the view. Delaying the positioning call doesn't help in this case.
@crisbeto Is there a solution to this problem? What is the recommended way to go?
Any update on this issue?
@crisbeto, @maku is there any workaround or patch for this issue?
This is somewhat tricky to fix on our end, because iOS seems to shift the coordinate grid when it focuses the into view, which makes it so we can't recalculate the position correctly. The best approach for now might be to disable scrolling for the autocomplete altogether. See https://github.com/angular/material2/issues/5187#issuecomment-324371834.
@crisbeto dump question - how do other ui libraries handle this problem?
The easiest way to handle it would be to use position: absolute to position the panel, however that is problematic when dealing with focus and overflow.
@crisbeto I would really appreciate an advice what to do... - should we drop using autocomplete?? and looking for an alternative (also the fix #5187 does not work for me) Is there anything in the pipeline? The component as it is is NOT usable on IOS.
Just to be curious - what problems does material2 have what other libs don't have (so that this stuff works on IOS)?
@crisbeto I really do not want to be annoying. But is there any kind of solution on the horizon?
Any updates? using latest and issue with iOS positioning as well as touch. I can not select an item from autoComplete component. I'm using the code from your example to test. I have hammer js installed the toggle button works and requires hammer js as per your spec. Not sure why I can not select an item but positioning is still an issue. Thanks!
This very issue is causing headaches on my side too.
The following two suggestions have helped the situation and make the autocomplete somewhat usable on iOS:
We have a related issue, maybe it's the same.
For us, the dropdown list gets hidden entirely by the keyboard, instead of the dropdown list going upwards (the autosuggest field is in the middle of the page).
https://imgur.com/a/nrBUw
Any updates on this issue?! I'm facing the same problem!!
Just want to add my thoughts on this. As I am facing this issue as well. Not sure if any of this information will help, but figured to add some notes here.
When testing on an iPad in debug mode connected to a MacBook, I noticed that when highlighting the AutoCompletePanel in the HTML element in the debugger, it does highlight the element, and the highlight is shown directly underneath the input field. So the positioning of the css is correct.
But the kicker is that the browser is rendering the auto complete panel NOT where the highlighted HTML is. Which leads me to believe that it is something with how iOS Safari is rendering the HTML elements while the keyboard is up.
This is just a comment supporting @crisbeto comment regaring iOS shifting it's coordinate grid.