Skip to content

fix(virtual-scroll): fix several small bugs #13597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 15, 2018

Conversation

mmalerba
Copy link
Contributor

fixes include:

  • ensure content wrapper is at least as wide as the viewport
  • run change detection when data source emits but the data length remains the same
  • improve error message when no virtual scroll strategy is provided
  • add docs on using a custom virtual scroll strategy

fixes include:
* ensure content wrapper is at least as wide as the viewport
* run change detection when data source emits but the data length remains the same
* improve error message when no virtual scroll strategy is provided
* add docs on using a custom virtual scroll strategy
@mmalerba mmalerba added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful target: patch This PR is targeted for the next patch release labels Oct 12, 2018
@mmalerba mmalerba requested a review from crisbeto as a code owner October 12, 2018 21:53
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 12, 2018
throw Error('Error cdk-virtual-scroll-viewport: You must specify a VirtualScrollStrategy.' +
' Either set the itemSize property or see the "Scrolling strategies" section at' +
' https://material.angular.io/cdk/scrolling for more on setting a virtual' +
' scrolling strategy');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since only the fixed-size is supported directly, I would just make the error

cdk-virtual-scroll-viewport requires the "itemSize" property to be set.

When autoSize is supported, the message can be updated. Even though you can also specify a custom strategy, I believe 99% of users will only ever use the built-in ones.

same API as [`*ngFor`](https://angular.io/api/common/NgForOf). In addition to the viewport and
virtual for, a `VirtualScrollStrategy` must be provided to the viewport. This is most easily
accomplished by setting the `itemSize` property on the viewport (for more see
[scrolling strategies](#scrolling-strategies)). The simplest usage just specifies the list of items:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this section of the docs, I wouldn't mention the strategy and just say that itemSize is required. Then, in the section below you can talk about custom strategies.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Oct 12, 2018
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -111,3 +111,13 @@ that the parent does not introduce additional space (e.g. via `margin` or `paddi
interfere with the scrolling.

<!-- example(cdk-virtual-scroll-dl) -->

### Scrolling strategies
In order to determine how large the overall content is and what porting of it actually needs to be
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

porting -> portion

### Scrolling strategies
In order to determine how large the overall content is and what porting of it actually needs to be
rendered at any given time the viewport relies on a `VirtualScrollStrategy` being provided. The
simplest way to provide this is to use the `itemSize` directive on the viewport
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this -> it

@Optional() dir: Directionality,
scrollDispatcher: ScrollDispatcher) {
super(elementRef, scrollDispatcher, ngZone, dir);

if (!this._scrollStrategy) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's the constructor you can use just if (!_scrollStrategy).


<!-- example(cdk-virtual-scroll-overview) -->

`*cdkVirtualFor` makes the following context variables available to the template:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this line got duplicated.

@andrewseguin andrewseguin merged commit 8cfaeea into angular:master Oct 15, 2018
roboshoes pushed a commit to roboshoes/material2 that referenced this pull request Oct 23, 2018
* fix(virtual-scroll): fix several small bugs

fixes include:
* ensure content wrapper is at least as wide as the viewport
* run change detection when data source emits but the data length remains the same
* improve error message when no virtual scroll strategy is provided
* add docs on using a custom virtual scroll strategy

* address comments

* address feedback
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants