components icon indicating copy to clipboard operation
components copied to clipboard

md-autocomplete list doesn't stick on it's position when scrolling on iOS

Open molcik opened this issue 9 years ago • 30 comments

Bug

What is the expected behavior?

md-autocomplete list should stick on it's position when scrolling on iOS

What is the current behavior?

md-autocomplete list doesn't stick on it's position when scrolling on iOS

What are the steps to reproduce?

img_4562 img_4564 img_4563

What is the use-case or motivation for changing an existing behavior?

Current behavior avoids using this component, because in specific circumstances list gets out of the view rectangle.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Angular - 4.1.3 OS - iOS 10.2.1

Is there anything else we should know?

molcik avatar Jun 17 '17 16:06 molcik

Possible duplicate of #4557

RobJacobs avatar Jun 17 '17 19:06 RobJacobs

+1 I guess the minimum requirement should be "avoid to render the overlay on the input" ;)

whyvrafvr avatar Jun 20 '17 09:06 whyvrafvr

This should be working in beta.7. Can you give it another shot?

crisbeto avatar Jun 20 '17 18:06 crisbeto

I'm using @angular/material: 2.0.0-beta.7 and it doesn't work yet.

whyvrafvr avatar Jun 20 '17 18:06 whyvrafvr

No more chance on https://material.angular.io/components/autocomplete/examples

whyvrafvr avatar Jun 20 '17 18:06 whyvrafvr

Hi @molcik, did beta 7 solve your issue? I'm facing the same one.

whyvrafvr avatar Jun 21 '17 13:06 whyvrafvr

Still having the issue with beta 8

whyvrafvr avatar Jul 06 '17 19:07 whyvrafvr

img_7703

whyvrafvr avatar Jul 06 '17 19:07 whyvrafvr

#3745 should have fixed repositioning while scrolling. I however noticed myself that it did not reposition in my project. This is because my autocomplete is inside an element with scroll. My site is separated into 3 sections. sidenav, toolbar and content. Only content scrolls.

If I add a scrollbar to the entire site it works. But I only want the scrollbar on the content element (ie, not stretching over the toolbar).

grizzm0 avatar Jul 13 '17 11:07 grizzm0

Also have this issue. Tested in your docs and in our own project. iOS can be a bitch...

sonderbazz avatar Jul 27 '17 07:07 sonderbazz

See #5797 and see if that helps you. Not sure if it's the same issue or not. Can't try it as there's no plnkr.

grizzm0 avatar Jul 27 '17 07:07 grizzm0

@grizzm0 thx for the info :) but it sadly didn't solve my issue. So since the issue is also in the docs - I think the issue is still valid.

sonderbazz avatar Jul 27 '17 08:07 sonderbazz

Here's my Plunker where i added some <br> above the input to better test the scrolling behaviour on iOS.

The scrolling also gets triggered when the virtual keyboard slides from below.

screen shot 2017-08-02 at 10 58 33

BaimosTechnologies avatar Aug 02 '17 09:08 BaimosTechnologies

@PhilipSultanescu thanks

whyvrafvr avatar Aug 02 '17 22:08 whyvrafvr

Any update on this issue? If you open the angular material2 website on the mobile safari, this issue still exists. I think it relates to #6341

xiongemi avatar Aug 21 '17 20:08 xiongemi

Hi @xiongemi. Correct, it seems to be the same issue :(

whyvrafvr avatar Aug 23 '17 15:08 whyvrafvr

Hi, FYI I solved that issue by using custom MD_AUTOCOMPLETE_SCROLL_STRATEGY

import {
    MdAutocompleteModule,
    MD_AUTOCOMPLETE_SCROLL_STRATEGY,
    Overlay, Platform,
   ...
} from '@angular/material';

export function MD_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY(overlay: Overlay, platform: Platform) {
    return () => platform.IOS ? overlay.scrollStrategies.block() : overlay.scrollStrategies.reposition();
}

@NgModule({
    imports: [
        MdAutocompleteModule,
        ...
    ],
    providers: [
        ...
        {
            provide: MD_AUTOCOMPLETE_SCROLL_STRATEGY,
            deps: [Overlay, Platform],
            useFactory: MD_AUTOCOMPLETE_SCROLL_STRATEGY_FACTORY,
        },
    ],
})

aitboudad avatar Aug 23 '17 15:08 aitboudad

@aitboudad I get

'"node_modules/@angular/material/material"' has no exported member 'MD_AUTOCOMPLETE_SCROLL_STRATEGY'

when I try that. Any idea why? I'm on 2.0.0-beta.8

kevinaud avatar Aug 26 '17 21:08 kevinaud

@kevinaud MD_AUTOCOMPLETE_SCROLL_STRATEGY will be landed in beta.9 in the meantime you can use the build snapshots for angular/material

// package.json
"@angular/cdk": "angular/cdk-builds",
"@angular/material": "angular/material-builds",

aitboudad avatar Aug 27 '17 10:08 aitboudad

Oh okay, thanks for the help.

I've got that all working and the behavior is as expected on my computer, it won't allow scrolling while the autocomplete is open, but its still messed up on my iphone for some reason... As soon as I focus on the autocomplete and the keyboard opens up it moves my view down so the autocomplete is no longer visible.

kevinaud avatar Aug 27 '17 16:08 kevinaud