Skip to content
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

feat(cdk/scrolling): extend CdkVirtualForOf to work with iterables #20210

Closed
howardjing opened this issue Aug 6, 2020 · 1 comment · Fixed by #20594
Closed

feat(cdk/scrolling): extend CdkVirtualForOf to work with iterables #20210

howardjing opened this issue Aug 6, 2020 · 1 comment · Fixed by #20594
Labels
area: cdk/scrolling feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions

Comments

@howardjing
Copy link
Contributor

howardjing commented Aug 6, 2020

Feature Description

Currently CdkVirtualForOf supports data from an Array, Observable<Array>, or DataSource. I would like it to support data from an Iterable as well. This would match the behavior of NgForOf which supports elements of both T[] and Iterable<T>.

According to the documentation at https://material.angular.io/cdk/scrolling/overview#creating-items-in-the-viewport, *cdkVirtualFor supports the exact same API as *ngFor. However *ngFor supports iterables while *cdkVirtualFor does not.

See https://stackblitz.com/edit/angular-bnbcza?file=src%2Fapp%2Fcdk-virtual-scroll-context-example.html for an example. In the linked example, using cdkVirtualFor does not render the set, while ngFor does render the set.

Use Case

This would make cdkVirtualFor closer to ngFor. I'm happy to try to implement this myself and create a PR, although I don't know how involved that would be.

@howardjing howardjing added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Aug 6, 2020
@jelbourn jelbourn added area: cdk/scrolling P4 A relatively minor issue that is not relevant to core functions and removed needs triage This issue needs to be triaged by the team labels Aug 6, 2020
howardjing added a commit to howardjing/components that referenced this issue Sep 17, 2020
The previous usage of `Array.prototype.slice.call` does not handle `Set`
objects appropriately (since a `Set` does not have a `length` property).
Updated it to use `Array.from`.

addresses angular#20210
howardjing added a commit to howardjing/components that referenced this issue Sep 17, 2020
The previous usage of `Array.prototype.slice.call` does not handle `Set`
objects appropriately (since a `Set` does not have a `length` property).
Updated it to use `Array.from`.

addresses angular#20210
howardjing added a commit to howardjing/components that referenced this issue Sep 17, 2020
The previous usage of `Array.prototype.slice.call` does not handle `Set`
objects appropriately (since a `Set` does not have a `length` property).
Updated it to use `Array.from`.

addresses angular#20210
howardjing added a commit to howardjing/components that referenced this issue Sep 27, 2020
The previous usage of `Array.prototype.slice.call` does not handle `Set`
objects appropriately (since a `Set` does not have a `length` property).
Updated it to use `Array.from`.

Fixes angular#20210.
jelbourn pushed a commit that referenced this issue Oct 20, 2020
The previous usage of `Array.prototype.slice.call` does not handle `Set`
objects appropriately (since a `Set` does not have a `length` property).
Updated it to use `Array.from`.

Fixes #20210.
jelbourn pushed a commit that referenced this issue Oct 20, 2020
The previous usage of `Array.prototype.slice.call` does not handle `Set`
objects appropriately (since a `Set` does not have a `length` property).
Updated it to use `Array.from`.

Fixes #20210.

(cherry picked from commit e15f82c)
@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 Nov 20, 2020
wagnermaciel pushed a commit to wagnermaciel/components that referenced this issue Jan 14, 2021
…ar#20594)

The previous usage of `Array.prototype.slice.call` does not handle `Set`
objects appropriately (since a `Set` does not have a `length` property).
Updated it to use `Array.from`.

Fixes angular#20210.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: cdk/scrolling feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants