Skip to content

Commit 51b9ca6

Browse files
authored
fix(Table): double click col trigger ResizeColumnCallback (#6809)
* fix(Table): double click col trigger ResizeColumnCallback * chore: bump version 9.11.1-beta01
1 parent 73f133a commit 51b9ca6

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.11.0</Version>
4+
<Version>9.11.1-beta01</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -617,16 +617,7 @@ const setResizeListener = table => {
617617
}
618618
tableEl.setAttribute('style', `width: ${width}px;`)
619619

620-
if (table.options.showColumnWidthTooltip) {
621-
const tip = bootstrap.Tooltip.getInstance(col);
622-
if (tip && tip._isShown()) {
623-
const inner = tip.tip.querySelector('.tooltip-inner');
624-
const tipText = getColumnTooltipTitle(table.options, colWidth + marginX);
625-
inner.innerHTML = tipText;
626-
tip._config.title = tipText;
627-
tip.update();
628-
}
629-
}
620+
resetColumnWidthTips(table, col);
630621

631622
const header = col.parentElement;
632623
if (header.classList.contains('fixed')) {
@@ -680,13 +671,26 @@ const resizeNextFixedColumnWidth = (col, width) => {
680671
}
681672
}
682673

674+
const resetColumnWidthTips = (table, col) => {
675+
if (table.options.showColumnWidthTooltip) {
676+
const tip = bootstrap.Tooltip.getInstance(col);
677+
if (tip && tip._isShown()) {
678+
const inner = tip.tip.querySelector('.tooltip-inner');
679+
const tipText = getColumnTooltipTitle(table.options, col.closest('th'));
680+
inner.innerHTML = tipText;
681+
tip._config.title = tipText;
682+
tip.update();
683+
}
684+
}
685+
}
686+
683687
const setColumnResizingListen = (table, col) => {
684688
if (table.options.showColumnWidthTooltip) {
685689
EventHandler.on(col, 'mouseenter', e => {
686690
closeAllTips(table.columns, e.target);
687691
const th = col.closest('th');
688692
const tip = bootstrap.Tooltip.getOrCreateInstance(e.target, {
689-
title: getColumnTooltipTitle(table.options, th.offsetWidth),
693+
title: getColumnTooltipTitle(table.options, th),
690694
trigger: 'manual',
691695
placement: 'top',
692696
customClass: 'table-resizer-tips'
@@ -698,8 +702,8 @@ const setColumnResizingListen = (table, col) => {
698702
}
699703
}
700704

701-
const getColumnTooltipTitle = (options, width) => {
702-
return `${options.columnWidthTooltipPrefix}${width}px`;
705+
const getColumnTooltipTitle = (options, th) => {
706+
return `${options.columnWidthTooltipPrefix}${th.offsetWidth}px`;
703707
}
704708

705709
const indexOfCol = col => {
@@ -742,6 +746,12 @@ const autoFitColumnWidth = async (table, col) => {
742746
});
743747

744748
setTableDefaultWidth(table);
749+
750+
if (table.options.resizeColumnCallback) {
751+
await table.invoke.invokeMethodAsync(table.options.resizeColumnCallback, index, maxWidth)
752+
}
753+
754+
resetColumnWidthTips(table, col);
745755
}
746756
}
747757

0 commit comments

Comments
 (0)