@@ -57,6 +57,7 @@ public partial class FluentDataGrid<TGridItem> : FluentComponentBase, IHandleEve
5757 private bool ? _lastVirtualizationMode ;
5858 private GridItemsProvider < TGridItem > ? _lastAssignedItemsProvider ;
5959 private CancellationTokenSource ? _pendingDataLoadCancellationTokenSource ;
60+ private bool _isFirstVirtualizeProviderCall = true ;
6061 private Exception ? _lastError ;
6162 private GridItemsProviderRequest < TGridItem > ? _lastRequest ;
6263 private bool _forceRefreshData ;
@@ -443,7 +444,7 @@ public FluentDataGrid(LibraryConfiguration configuration) : base(configuration)
443444
444445 // Returns Loading if set (controlled). If not controlled,
445446 // we assume the grid is loading until the next data load completes
446- internal bool EffectiveLoadingValue => Loading ?? ItemsProvider is not null ;
447+ internal bool EffectiveLoadingValue => Loading ?? ( ItemsProvider is not null ) ;
447448
448449 /// <summary>
449450 /// Indicates whether the grid is currently sorted ascending.
@@ -796,7 +797,7 @@ public async Task RemoveSortByColumnAsync(ColumnBase<TGridItem> column)
796797 await OnSortChanged . InvokeAsync ( new ( )
797798 {
798799 Column = _sortByColumn ,
799- SortByAscending = _sortByAscending
800+ SortByAscending = _sortByAscending ,
800801 } ) ;
801802 }
802803
@@ -994,11 +995,16 @@ private async Task RefreshDataCoreAsync()
994995 private async ValueTask < ItemsProviderResult < ( int , TGridItem ) > > ProvideVirtualizedItemsAsync ( ItemsProviderRequest request )
995996 {
996997 _lastRefreshedPaginationState = Pagination ;
998+ // Debounce the requests (except on first call). This eliminates a lot of redundant queries at the cost of slight lag after interactions.
999+ if ( _isFirstVirtualizeProviderCall )
1000+ {
1001+ _isFirstVirtualizeProviderCall = false ;
1002+ }
1003+ else
1004+ {
1005+ await Task . Delay ( 20 ) ;
1006+ }
9971007
998- // Debounce the requests. This eliminates a lot of redundant queries at the cost of slight lag after interactions.
999- // TODO: Consider making this configurable, or smarter (e.g., doesn't delay on first call in a batch, then the amount
1000- // of delay increases if you rapidly issue repeated requests, such as when scrolling a long way)
1001- await Task . Delay ( 20 ) ;
10021008 if ( request . CancellationToken . IsCancellationRequested )
10031009 {
10041010 return default ;
0 commit comments