Skip to content

Commit

Permalink
WebUI: Update sort icon after changing column order
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
skomerko authored Feb 23, 2025
1 parent 1ca33d4 commit ba3d89b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/webui/www/private/scripts/dynamicTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ window.qBittorrent.DynamicTable ??= (() => {
this.setupCommonEvents();
this.setupHeaderEvents();
this.setupHeaderMenu();
this.setSortedColumnIcon(this.sortedColumn, null, (this.reverseSort === "1"));
this.setupAltRow();
},

Expand Down Expand Up @@ -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));
}
}
},

Expand Down

0 comments on commit ba3d89b

Please sign in to comment.