-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
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
- Extract the ItemsProviderReproduction.zip ItemsProviderReproduction.zip
- Open the ItemsProvider.sln
- Run up the application
- 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
- 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.
- Open Home.razor and go to line 56 and comment out the await Task.Delay
- Run up the application
- 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.