Skip to content

Commit 1c5b657

Browse files
committed
Fix column width calculation in autoFitColumnWidth
调整参数 fitColumnWidthIncludeHeader 设置后,最大宽度的比较方式。
1 parent 21238ea commit 1c5b657

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/BootstrapBlazor/Components/Table/Table.razor.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,10 @@ const autoFitColumnWidth = async (table, col) => {
747747
const span = th.querySelector('.table-cell');
748748
const thStyle = getComputedStyle(th);
749749
const margin = parseFloat(thStyle.getPropertyValue('padding-left')) + parseFloat(thStyle.getPropertyValue('padding-right'))
750-
maxWidth = Math.max(maxWidth, calcCellWidth(span)) + margin;
750+
751+
//当 maxWidth 超过 列头span宽度 时,计算结果会额外的多出 margin 这个值
752+
//应该是 maxWidth 与 (列头span宽度 + margin值)比较取最大
753+
maxWidth = Math.max(maxWidth, calcCellWidth(span) + margin);
751754
}
752755

753756
if (table.options.autoFitColumnWidthCallback !== null) {

0 commit comments

Comments
 (0)