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

Awaiting for some time in the ItemsProvider method in the Virtualize component and the user scrolling leads to unpredictable scrolling behaviour #61156

Open
ben-goldie opened this issue Mar 25, 2025 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components investigate Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update.
Milestone

Comments

@ben-goldie
Copy link

Description

When a user scrolls using the scrollbar in the Virtualize component when awaiting (Task.Delay) is performed in the ItemsProvider method the scrollbar moves unpredictably.

When the awaiting (Task.Delay) is removed when a user scrolls using the scrollbar then the scrollbar moves as expected.

When the awaiting is done it appears to cancel ItemsProvider call via the CancellationToken. Perhaps I am not handling the cancelling request appropriately. Please see the reproduction steps.

Reproduction Steps

  1. Extract the ItemsProviderReproduction.zip ItemsProviderReproduction.zip
  2. Open the ItemsProvider.sln
  3. Run up the application
  4. Scroll the Virtualize component several times, wait a few seconds between some scrolls so that the 1 second task delay on the simulated service calls can completed and display items
  5. Notice that occasionally the scrollbar will jump forward and back unpredictably which is not expected. Also notice that the numbered item (which are sequential) will also confirm that it is scrolling unpredictably.
  6. Open Home.razor and go to line 56 and comment out the await Task.Delay
  7. Run up the application
  8. Scroll the Virtualize component several times, notice that no unpredictable scrolling is observed.

Expected behavior

Scrolling with awaiting Task.Delay should not lead to unpredictable scrolling.

Actual behavior

When scrolling with the await occasionally the scrollbar will jump forward and back unpredictably which is not expected. Also notice that the numbered item (which are sequential) will also confirm that it is scrolling unpredictably.

Regression?

I have not tried in previous versions

Known Workarounds

Don't await in the ItemsProvider call, instead return loading items and previously loaded total and use a ContinueWith on the service task and update the items when the service task resolves.

Configuration

.NET 8 windows 11

Other information

I think it is related to how cancelled ItemsProvider requests are handled.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Mar 25, 2025
@jeffschwMSFT jeffschwMSFT transferred this issue from dotnet/runtime Mar 25, 2025
@Kahbazi Kahbazi added area-blazor Includes: Blazor, Razor Components and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Mar 26, 2025
@javiercn
Copy link
Member

@ben-goldie thanks for contacting us.

Please provide the project repro as a public github repository.

@javiercn javiercn added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed untriaged labels Mar 26, 2025
@maritogram
Copy link

Able to reproduce, here's the repo (the zip basically): https://github.com/maritogram/ViirtualizedAsyncItemsProvider

@ben-goldie
Copy link
Author

Thank you for the help @maritogram !

@dotnet-policy-service dotnet-policy-service bot added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Mar 26, 2025
@danroth27 danroth27 added this to the Backlog milestone Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components investigate Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update.
Projects
None yet
Development

No branches or pull requests

5 participants