[Bugfix:Forum] Fix stats header rendering#12698
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a rendering bug on the forum stats page where clicking sortable headers could cause header labels to show escaped HTML, by correcting the table structure and updating the client-side sorting/expand logic to avoid relying on header HTML.
Changes:
- Updated the forum stats table markup to use a proper
<thead>/<tbody>structure and removed<a href="#">inside<th>cells. - Replaced the previous
sortTableusage with a forum-stats-specific sorting implementation that sorts grouped user/detail rows and updates sort indicators via text. - Refactored expand/collapse row insertion/removal and moved thread navigation to a delegated cell-click handler.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| site/public/js/stat-page.js | Reworks sorting and expand/collapse logic to avoid .html()-based header mutations and preserve grouped rows. |
| site/app/templates/forum/StatPage.twig | Fixes invalid table structure by adding <thead>/<tbody> and removes header anchor tags that were contributing to escaped HTML rendering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <th class="cursor-pointer" style="width:15%" id="user_sort">User</th> | ||
| <th class="cursor-pointer" id="total_posts_sort">Total Posts (not deleted)</th> | ||
| <th class="cursor-pointer" style="width:15%" id="total_threads_sort">Total Threads</th> | ||
| <th class="cursor-pointer" style="width:15%" id="total_deleted_sort">Total Deleted Posts</th> | ||
| <th class="cursor-pointer" style="width:15%" id="total_upducks">Total Upducks</th> | ||
| <th style="width:25%">Show Posts</th> |
There was a problem hiding this comment.
Sortable column headers were changed from links to plain text with a click handler. This makes sorting inaccessible to keyboard users because is not focusable by default and doesn't respond to Enter/Space. Consider rendering the sortable header content as a (or an with proper prevention) inside the , or add tabindex="0" + role="button" and a keydown handler (Enter/Space) to trigger sorting.
|
Nice fix — the root cause makes sense. Using .html() on headers that contained tags was causing the escaped HTML to show up after sorting. Fixing the table structure with proper / and removing the anchor tags from the headers is a clean approach. |
There was a problem hiding this comment.
Great catch on this issue! The new change functions well. Have you considered using the same sorting headers that we use on other pages (see the Docker UI, pending gradeables, and grading page). We should use it here since we are already cleaning up the headers and it would make the page becomes consistent with the rest of the site.
Here is a screenshot of the headers from the grade details page:

|
Thanks! I updated it to use the shared sortable header pattern and kept the forum-specific grouped-row sorting intact. Tested locally as well. |
| const timestamps = $(this).data('timestamps'); | ||
| const thread_ids = $(this).data('thread_id'); | ||
| const thread_titles = $(this).data('thread_titles'); | ||
|
|
|
Thanks for pointing this out! I updated the forum stats table so expanding posts no longer shifts the overall table layout, and the expand/collapse button now stays in a stable position. I also removed the extra whitespace in the JS change. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12698 +/- ##
=========================================
Coverage 21.67% 21.67%
Complexity 9806 9806
=========================================
Files 268 268
Lines 36724 36724
Branches 489 489
=========================================
Hits 7960 7960
Misses 28279 28279
Partials 485 485
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
* main: (50 commits) [Bugfix:Developer] Fix Broken CI (#12851) [Bugfix:System] Restore TCLAPP (#12850) [Bugfix:Submission] Fix non-VCS repo error (#12608) [Feature:Submission] Jupyter warnings outside notebook (#12523) [Bugfix:InstructorUI] Removed feature flag for Bulk Late Days (#12826) [Bugfix:Forum] Fix stats header rendering (#12698) [Bugfix:Autograding] Fix negative number tolerance (#12569) [Bugfix:HelpQueue] Always use Abbreviated Names in OH (#12820) [Bugfix:Autograding] Fix regrade team detection (#12737) [Dependency] Bump Lichen from v23.09.00 to v26.04.01 (#12823) [Dependency] Bump RainbowGrades from v25.10.00 to v26.04.01 (#12824) [Feature:Developer] Remove misc Java utils and TCLAPP (#12819) [Bugfix:TAGrading] Fix 2-panel open-document select (#12577) [Dependency] Bump AnalysisToolsTS from v23.10.00 to v26.04.00 (#12822) [Bugfix:Developer] Fix bump_repo permissions (#12821) [Bugfix:InstructorUI] Change Colors to match in Docker UI table (#12739) [Bugfix:Forum] Reduce Page Caching (#12339) [Bugfix:System] File lost when running install clean fix (#12158) [Bugfix:Submission] No File Rubric submit all user groups (#12812) [Dependency] Bump twig/markdown-extra from 3.23.0 to 3.24.0 in /site (#12721) ...



Why is this Change Important & Necessary?
Fixes #12697
Clicking sortable headers on the forum stats page can cause header labels to render as escaped HTML due to invalid table structure and use of
.html()during sorting.What is the New Behavior?
Headers remain properly rendered as plain text after sorting, and no escaped HTML appears. Sorting and expand/collapse functionality continue to work correctly.
Demo (screen recording):
https://github.com/user-attachments/assets/8dc62a31-5764-4c37-80b9-67c07fc468f1
What steps should a reviewer take to reproduce or test the bug or new feature?
/forum/statsAutomated Testing & Documentation
No automated tests or documentation changes were required.
Other information