Skip to content

Commit 3e9f839

Browse files
committed
refactor: 重构代码
1 parent 949b10e commit 3e9f839

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/BootstrapBlazor/Components/Table/Table.razor.Pagination.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public partial class Table<TItem>
148148
}
149149
};
150150

151+
private bool _shouldScrollTop = false;
151152
/// <summary>
152153
/// 点击页码调用此方法
153154
/// </summary>
@@ -171,9 +172,9 @@ protected async Task OnPageLinkClick(int pageIndex)
171172
await OnSelectedRowsChanged();
172173

173174
// 通知 UI 滚动到顶端
174-
if(IsAutoScrollTopWhenClickPage)
175+
if (IsAutoScrollTopWhenClickPage)
175176
{
176-
await InvokeVoidAsync("scrollTop", Id);
177+
_shouldScrollTop = true;
177178
}
178179
}
179180
}

src/BootstrapBlazor/Components/Table/Table.razor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,13 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
10181018
if (_isFilterTrigger)
10191019
{
10201020
_isFilterTrigger = false;
1021+
_shouldScrollTop = false;
1022+
await InvokeVoidAsync("scrollTo", Id);
1023+
}
1024+
1025+
if(_shouldScrollTop)
1026+
{
1027+
_shouldScrollTop = false;
10211028
await InvokeVoidAsync("scrollTo", Id);
10221029
}
10231030

0 commit comments

Comments
 (0)