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

bug(cdk-virtual-scroll-viewport): If there is not enough data without caching, the scrolling operation will be invalid. #29945

Open
soulxy opened this issue Oct 31, 2024 · 0 comments
Labels
area: cdk/scrolling needs investigation A member of the team needs to do further investigation to determine the root cause P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@soulxy
Copy link

soulxy commented Oct 31, 2024

Is this a regression?

No response

Description

If there is not enough data without caching, the scrolling operation will be invalid.

Reproduction

StackBlitz link:https://stackblitz.com/edit/angular-sbfsdw?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fng-zorro-antd.module.ts,src%2Fapp%2Fapp.module.ts
Steps to reproduce:

  1. If you scroll the mouse in the container, the scroll bar will always react, resulting in unsuccessful scrolling.
  2. If you drag the scroll bar directly, you can basically scroll normally, and if the data length is in a certain interval, there will be obvious problems of unsuccessful scrolling.

The core code is as follows:

@Component({
  selector: 'nz-demo-button-basic',
  template: `
   <cdk-virtual-scroll-viewport itemSize="250" class="example-viewport">
  <div *cdkVirtualFor="let item of items; templateCacheSize: 0" class="example-item">
  <app-my [name]="name"></app-my>
  <!-- <div class="analysis-middle-indicators-charts" style="height: 250px;">
         <app-my [name]="name"></app-my>
      </div> -->
  </div>
</cdk-virtual-scroll-viewport>
  `,
  styles: [
    `
   .example-viewport {
  height: 600px;
  width: 200px;
  border: 1px solid black;
}

.example-item {
  height: 250px;
  border: 1px solid red;
}
    `,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NzDemoButtonBasicComponent {
  // length 20000 scroll working
  // length 20 scroll no working
  items = Array.from({ length: 20 }).map((_, i) => `Item #${i}`);
}

Expected Behavior

No matter the size of itemsize or the amount of data, the scrolling effect is normal.

Actual Behavior

Unable to scroll up and down

Environment

  • Angular: 16+、18+
  • CDK/Material: 16+、18+
  • Browser(s):
  • Operating System (e.g. Windows, macOS, Ubuntu):
@soulxy soulxy added the needs triage This issue needs to be triaged by the team label Oct 31, 2024
@wagnermaciel wagnermaciel added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent needs investigation A member of the team needs to do further investigation to determine the root cause area: cdk/scrolling and removed needs triage This issue needs to be triaged by the team labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/scrolling needs investigation A member of the team needs to do further investigation to determine the root cause P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

2 participants