Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 3897385

Browse files
committed
rename a sorted column label now is refreshed correctly
1 parent e27c65e commit 3897385

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/components/HeaderMenu.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,21 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
115115
o === column.id ? newKey : o
116116
);
117117
table.setColumnOrder(updateOrderWithNewKey);
118-
// Update state of altered column
118+
119119
setkeyState(newKey);
120+
121+
// Update sorted columns
122+
if (column.getIsSorted()) {
123+
const alterSort = table.options.state.sorting.map((o) => {
124+
if (o.id === column.id) {
125+
o.id = newKey;
126+
}
127+
return o;
128+
});
129+
table.setSorting(alterSort);
130+
}
131+
132+
// Update state of altered column
120133
columnActions
121134
.alterColumnLabel(column.columnDef as TableColumn, labelState)
122135
.then(() => {

0 commit comments

Comments
 (0)