Fossil

View Ticket
Login
Ticket Hash: 59d699710b1ab5d4322568b5a4576f489ffe72d7
Title: Bug in combination of ticket reports with additional rows and sorttable.js
Status: Open Type: Code_Defect
Severity: Important Priority:
Subsystem: Resolution:
Last Modified: 2025-04-06 14:56:32
106.6 days ago
Created: 2025-04-06 14:56:32
106.6 days ago
Version Found In:
sorttable vs. reports with additional rows

Problem

In reports you can enable additional rows per ticket, by declaring a values name with a leading underscore. The template for new reports includes an example of this.

Reproduction

Create a ticket report with additional rows per ticket. That works by simply using the default ticket report template. Or you can do it yourself by adding fields with a name that starts with an underscore (select x as _x). That is intentional and documented behaviour of the ticket report.

Look at this newly created report and then try to sort it by clicking on any column besides the first. It will do nothing and in the javascripot console you can see an error.

Analysis

If you do such report, then sorttable.js breaks on these additional rows. The reason is, that it tries to access the cell associated with the column that you are currently sorting for. For instance if you sort for the third column, then it tries to read the content of the third cell. But the additional rows use a colspan to only have one cell. So the code accesses a non-existant cell and breaks with the following error:

2:884 Uncaught TypeError: Cannot read properties of undefined (reading 'textContent')
    at SortableTable.sortText (2:884:17)
    at Array.sort (<anonymous>)
    at SortableTable.sort (2:856:9)
    at SortableTable.hdrcell.onclick (2:949:13)
SortableTable.sortText @ 2:884
SortableTable.sort @ 2:856
SortableTable.hdrcell.onclick @ 2:949

Solution

First it is needed to fix the break and make the sorting work at least for the columns with content. (see: quickfix)

But long-term it would be best if the additional rows are somehow glued to the initial rows and move together with them. That probably means that these additional columns need to be marked in some way, that the Javascript code can detect.

User Comments:
jkosche added on 2025-04-06 14:56:32:

There is a bug if you enable reports with mutiple rows per ticket (by declaring a value name with a leading underscore), then sorttable.js breaks on these additional rows.