Skip to content

cdk-virtual-scroll-viewport: this.viewPort._scrollStrategy._viewPort is null #15412

Open
@supdegrave

Description

@supdegrave

What is the expected behavior?

On return to list view in step 4, the item clicked in step 3 below should smooth-scroll into view, and be displayed with a different background color.

What is the current behavior?

The item clicked in step 3 does not scroll into view. Manually scrolling to it shows that it is displayed with a different background color.

What are the steps to reproduce?

https://stackblitz.com/edit/cdk-virtual-scroll-viewport-null

  1. click "view lesson list", navigate to "/lessons"
  2. scroll list so that initial items are not in view
  3. click an item, navigate to "/lesson;lessonId=xxxxx"
  4. click "Greetings from lesson xxxxx", navigate to "/lessons;lessonId=xxxxx"

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

Angular: 7
Angular Material: 7
OS: macOS Sierra
Browsers: Chrome Canary (74.0.3720.5), Chrome (72.0.3626.121), Safari (12.0.3 (12606.4.5.3.1)),

Is there anything else we should know?

To debug, open ./src/app/lesson-list/lesson-list.component.ts and find the method scrollToLessonById. Set a breakpoint on:

this.viewPort.scrollToIndex(lessonIndex, 'smooth');

Stepping into this, you should find that this.viewPort._scrollStrategy._viewPort is null, causing the underlying this._viewport.scrollToOffset to not be called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsanimationThis issue is related to Angular animations or CSS animationsarea: cdk/scrollingperfThis issue is related to performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions