From e3b690736d3134471b3588a3f9e1a7c7afb3c2d5 Mon Sep 17 00:00:00 2001 From: Tony <6914529@qq.com> Date: Sun, 31 May 2026 22:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E4=B8=AD=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E5=88=97=E6=97=B6=EF=BC=88=E5=B7=A6/?= =?UTF-8?q?=E5=8F=B3=EF=BC=89=EF=BC=8C=E8=AE=A9=E7=BB=84=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?DefaultFixedColumnWidth=E5=B1=9E=E6=80=A7=E5=80=BC=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix:让参数,DefaultFixedColumnWidth,生效 refactor: 修改单元测试 desc:当列固定时,默认固定列宽度没给到表格上,导致用户在改变表格列宽时,导致表格会整体重算列宽时,将固定列宽错误重计算,但固定列上style中left或right的值还是默认的200px,从而在横向滑动时出现错位 --- src/BootstrapBlazor/Components/Table/Table.razor.cs | 2 +- test/UnitTest/Components/TableTest.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.cs b/src/BootstrapBlazor/Components/Table/Table.razor.cs index 96653667e04..8b71d314d81 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.cs @@ -1448,7 +1448,7 @@ private void ResetTableColumns() { DisplayName = col.GetDisplayName(), Name = col.GetFieldName(), - Width = col.Width, + Width = col.Fixed && !col.Width.HasValue ? DefaultFixedColumnWidth : col.Width, Visible = col.GetVisible(_screenSize) }; diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs index 4652c53e943..295f1982f4c 100644 --- a/test/UnitTest/Components/TableTest.cs +++ b/test/UnitTest/Components/TableTest.cs @@ -1845,6 +1845,14 @@ public void ColumnFixed_Ok(bool showExtendButton, bool isFixedHeader) cut.Contains("left: 0px;"); cut.Contains("left: 200px;"); + var columns = cut.FindAll("th"); + var col = cut.FindAll("col"); + if (columns[0].ClassName == "fixed") + { + var fixedWidth = cut.FindAll("col")[0].OuterHtml.Contains("width: 200px"); + Assert.Equal("fixedWidth:True", $"fixedWidth:{fixedWidth}"); + } + if (showExtendButton) { if (isFixedHeader)