WebUI: Update sort icon after changing column order

This PR fixes a bug where the sort icon did not update correctly after reordering columns.

Steps to reproduce:
1. Sort a column
2. Move it to a different position
3. The sort icon remains in its original location

PR #22299.
This commit is contained in:
skomerko 2025-02-23 08:13:17 +01:00 committed by GitHub
commit ba3d89b674
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -89,7 +89,6 @@ window.qBittorrent.DynamicTable ??= (() => {
this.setupCommonEvents();
this.setupHeaderEvents();
this.setupHeaderMenu();
this.setSortedColumnIcon(this.sortedColumn, null, (this.reverseSort === "1"));
this.setupAltRow();
},
@ -600,19 +599,21 @@ window.qBittorrent.DynamicTable ??= (() => {
updateTableHeaders: function() {
this.updateHeader(this.hiddenTableHeader);
this.updateHeader(this.fixedTableHeader);
this.setSortedColumnIcon(this.sortedColumn, null, (this.reverseSort === "1"));
},
updateHeader: function(header) {
const ths = this.getRowCells(header);
for (let i = 0; i < ths.length; ++i) {
const th = ths[i];
th._this = this;
th.title = this.columns[i].caption;
th.textContent = this.columns[i].caption;
th.style.cssText = `width: ${this.columns[i].width}px; ${this.columns[i].style}`;
th.columnName = this.columns[i].name;
th.classList.add(`column_${th.columnName}`);
th.classList.toggle("invisible", ((this.columns[i].visible === "0") || this.columns[i].force_hide));
if (th.columnName !== this.columns[i].name) {
th.title = this.columns[i].caption;
th.textContent = this.columns[i].caption;
th.style.cssText = `width: ${this.columns[i].width}px; ${this.columns[i].style}`;
th.columnName = this.columns[i].name;
th.className = `column_${th.columnName}`;
th.classList.toggle("invisible", ((this.columns[i].visible === "0") || this.columns[i].force_hide));
}
}
},