Skip to content

Commit 4e82ec5

Browse files
committed
refactor: 更新 GetScrollStyleString 方法
1 parent 92091df commit 4e82ec5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/BootstrapBlazor/Components/Table/Table.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
}
199199

200200
<RenderTemplate OnRenderAsync="OnTableRenderAsync">
201-
<div class="@WrapperClassName">
201+
<div class="@WrapperClassName" style="@GetScrollStyleString(!IsFixedHeader)">
202202
@if (ActiveRenderMode == TableRenderMode.Table)
203203
{
204204
if (IsFixedHeader)
@@ -209,7 +209,7 @@
209209
@RenderHeader(true)
210210
</table>
211211
</div>
212-
<div class="table-fixed-body scroll" style="@ScrollStyleString">
212+
<div class="table-fixed-body scroll" style="@GetScrollStyleString(true)">
213213
@RenderTable(false)
214214
</div>
215215
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ private string GetSortTooltip(ITableColumn col) => SortName != col.GetFieldName(
186186

187187
private string ScrollWidthString => $"width: {ActualScrollWidth}px;";
188188

189-
private string ScrollStyleString => $"--bb-scroll-width: {ActualScrollWidth}px; --bb-scroll-hover-width: {ActualScrollHoverWidth}px;";
189+
private string? GetScrollStyleString(bool condition) => condition
190+
? $"--bb-scroll-width: {ActualScrollWidth}px; --bb-scroll-hover-width: {ActualScrollHoverWidth}px;"
191+
: null;
190192

191193
private int ActualScrollWidth => ScrollWidth ?? Options.CurrentValue.ScrollOptions.ScrollWidth;
192194

0 commit comments

Comments
 (0)