From 37e508f5c9003c2f086767559291f7118fb7e872 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 17 May 2026 16:55:47 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=8D=95=E5=85=83=E6=A0=BC=E5=AE=BD=E5=BA=A6=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Table/Table.razor.js | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.js b/src/BootstrapBlazor/Components/Table/Table.razor.js index 7fd362ee3e4..108142f6845 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.js +++ b/src/BootstrapBlazor/Components/Table/Table.razor.js @@ -627,6 +627,53 @@ const autoFitColumnWidth = async (table, col) => { } } +const formControlSelector = 'input.form-control:not([type="hidden"]), textarea.form-control'; + +const getHorizontalWidth = style => { + return (parseFloat(style.getPropertyValue('padding-left')) || 0) + + (parseFloat(style.getPropertyValue('padding-right')) || 0) + + (parseFloat(style.getPropertyValue('border-left-width')) || 0) + + (parseFloat(style.getPropertyValue('border-right-width')) || 0); +} + +const getFormControlTextWidth = control => { + const style = getComputedStyle(control); + const span = document.createElement('span'); + span.textContent = control.value || control.getAttribute('placeholder') || ' '; + span.style.setProperty('visibility', 'hidden'); + span.style.setProperty('white-space', 'pre'); + span.style.setProperty('display', 'inline-block'); + span.style.setProperty('position', 'absolute'); + span.style.setProperty('top', '0'); + span.style.setProperty('font-family', style.getPropertyValue('font-family')); + span.style.setProperty('font-size', style.getPropertyValue('font-size')); + span.style.setProperty('font-style', style.getPropertyValue('font-style')); + span.style.setProperty('font-weight', style.getPropertyValue('font-weight')); + span.style.setProperty('letter-spacing', style.getPropertyValue('letter-spacing')); + span.style.setProperty('text-transform', style.getPropertyValue('text-transform')); + document.body.appendChild(span); + + const width = getWidth(span) + getHorizontalWidth(style); + span.remove(); + + return width; +} + +const resetFormControlWidth = (sourceCell, cloneCell) => { + const controls = [...sourceCell.querySelectorAll(formControlSelector)]; + const cloneControls = [...cloneCell.querySelectorAll(formControlSelector)]; + controls.forEach((control, index) => { + const cloneControl = cloneControls[index]; + if (cloneControl) { + const width = getFormControlTextWidth(control); + cloneControl.value = control.value; + cloneControl.style.setProperty('width', `${width}px`, 'important'); + cloneControl.style.setProperty('min-width', '0', 'important'); + cloneControl.style.setProperty('flex', '0 0 auto', 'important'); + } + }); +} + const calcCellWidth = cell => { const div = document.createElement('div'); [...cell.children].forEach(c => { @@ -638,9 +685,13 @@ const calcCellWidth = cell => { div.style.setProperty('position', 'absolute'); div.style.setProperty('top', '0'); document.body.appendChild(div); + resetFormControlWidth(cell, div); const cellStyle = getComputedStyle(cell); - return getWidth(div) + parseFloat(cellStyle.getPropertyValue('padding-left')) + parseFloat(cellStyle.getPropertyValue('padding-right')) + parseFloat(cellStyle.getPropertyValue('border-left-width')) + parseFloat(cellStyle.getPropertyValue('border-right-width')) + 1 | 0; + const width = getWidth(div) + getHorizontalWidth(cellStyle) + 1 | 0; + div.remove(); + + return width; } const closeAllTips = (columns, self) => { From b140bad88ca6a85303a9c7e4fb35f70491cf202f Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 17 May 2026 16:56:10 +0800 Subject: [PATCH 2/3] chore: bump version 10.6.1-beta23 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index af5fbbed25f..470510ad18c 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 10.6.1-beta22 + 10.6.1-beta23 From 131f9b0ef2a0610a1fe6fffff081cd3951a2bbe8 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sun, 17 May 2026 16:56:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Table/Table.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.cs b/src/BootstrapBlazor/Components/Table/Table.razor.cs index 960c0987b55..74c70152a64 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.cs @@ -446,7 +446,7 @@ private string GetSortTooltip(ITableColumn col) => SortName != col.GetFieldName( /// /// 获得/设置 滚动行为,默认值为 /// Gets or sets the scroll behavior. The default is - /// v10.6.2 + /// v10.6.1 /// [Parameter] public ScrollIntoViewBehavior ScrollIntoViewBehavior { get; set; } = ScrollIntoViewBehavior.Smooth;