Description
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
- click "view lesson list", navigate to "/lessons"
- scroll list so that initial items are not in view
- click an item, navigate to "/lesson;lessonId=xxxxx"
- 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.