components icon indicating copy to clipboard operation
components copied to clipboard

Expansion panel expanded state issue with Virtual Scroll

Open trevorsmiley opened this issue 7 years ago • 15 comments
trafficstars

Bug, feature request, or proposal:

cdkVirtualScroll does not work properly with matAccordion and matExpansionPanel.

The accordion does not respect the expansion state of individual expansion panels as you scroll.

What is the expected behavior?

The expansion state is maintained as you scroll

What is the current behavior?

If you expand the xth item in the accordion then as you scroll, the xth in the view will always be expanded. ie if you expand the 3rd item then as you scroll down to say the 1000th item then the 1003rd item will be expanded.

What are the steps to reproduce?

Stackblitz example

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

Able to use expansion panels inside virtual scroll

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

Angular 7.0 Material 7.0 MacOS 10.14 TypeScript 3.x Browser Chrome 70.0

Is there anything else we should know?

No

trevorsmiley avatar Oct 19 '18 20:10 trevorsmiley

Looks like this is happening because the virtual scroll is reusing the template, which has a state that is not being reset.

josephperrott avatar Oct 19 '18 20:10 josephperrott

As a workaround you can set the template cache size for the cdkVirtualFor to 0 and since the template is not reused, it works as expected.

<mat-expansion-panel  *cdkVirtualFor="let item of items, templateCache = 0">

josephperrott avatar Oct 19 '18 21:10 josephperrott

<mat-expansion-panel  *cdkVirtualFor="let item of items; templateCacheSize: 0">

works as a work around

trevorsmiley avatar Oct 22 '18 13:10 trevorsmiley

@trevorsmiley

<mat-expansion-panel  *cdkVirtualFor="let item of items; templateCacheSize: 0">

Its not quiet good, because when u scroll with open element, everything is jumping.... When will be the fix for that @mmalerba

For now its not possible to use CDK virtual scroll with Angular Material Ui

mateBe95 avatar Jun 19 '19 07:06 mateBe95

@mmalerba any updates on this issue?

nFangueiro avatar Jun 19 '19 11:06 nFangueiro

??

mateBe95 avatar Jun 24 '19 13:06 mateBe95

??

ghost avatar Jul 29 '19 12:07 ghost

any updates on this issue?

KarenGrigoryan92 avatar Sep 11 '19 17:09 KarenGrigoryan92

+1

fasidOnGit avatar Apr 08 '20 14:04 fasidOnGit

any update? :)

Steefanieee avatar Jun 09 '20 12:06 Steefanieee

Still waiting for an update. It's been almost 2 years.

TolgaYigit avatar Jul 17 '20 13:07 TolgaYigit

4 years.

indiealexh avatar Apr 08 '22 05:04 indiealexh

5 years.

AsmisAlan avatar May 09 '23 15:05 AsmisAlan

6 years.

Aloui9 avatar Mar 18 '24 08:03 Aloui9

6 years. One more time.

Amrrx avatar Aug 09 '24 18:08 Amrrx