Skip to content

[Bugfix:Forum] Fix stats header rendering#12698

Merged
bmcutler merged 5 commits into
Submitty:mainfrom
not-so-shubh:bugfix/forum-stats-header-escape
May 1, 2026
Merged

[Bugfix:Forum] Fix stats header rendering#12698
bmcutler merged 5 commits into
Submitty:mainfrom
not-so-shubh:bugfix/forum-stats-header-escape

Conversation

@not-so-shubh

@not-so-shubh not-so-shubh commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

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?

  1. Go to /forum/stats
  2. Click sortable column headers
  3. Verify headers do not render escaped HTML
  4. Test sorting and expand/collapse functionality

Automated Testing & Documentation

No automated tests or documentation changes were required.


Other information

  • Not a breaking change
  • No migrations required
  • No security concerns

Copilot AI review requested due to automatic review settings March 30, 2026 19:21
@github-project-automation github-project-automation Bot moved this to Seeking Reviewer in Submitty Development Mar 30, 2026
@automateprojectmangement automateprojectmangement Bot moved this from Seeking Reviewer to In Review in Submitty Development Mar 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sortTable usage 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.

Comment thread site/app/templates/forum/StatPage.twig Outdated
Comment on lines +17 to +22
<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>

Copilot AI Mar 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@Khine12

Khine12 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

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.
One thing worth noting — Copilot flagged that removing the tags from the sortable headers means they're no longer keyboard-focusable. Adding tabindex="0" and role="button" with a keydown handler for Enter/Space would keep the sorting accessible for keyboard users.
The screen recording in the issue (#12697) was helpful for understanding the bug. Good work!

@JManion32 JManion32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Image

@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Mar 31, 2026
@not-so-shubh

Copy link
Copy Markdown
Contributor Author

Thanks! I updated it to use the shared sortable header pattern and kept the forum-specific grouped-row sorting intact. Tested locally as well.

@not-so-shubh
not-so-shubh requested a review from JManion32 April 1, 2026 21:11
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Apr 1, 2026

@JManion32 JManion32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Functionality and code looks reasonable, but I noticed a small bug:

When user posts are expanded, it shifts the entire table layout.
Main:
Image
Your Branch:
Image

It's good UI/UX to have the expand and collapse buttons in the same spot. Currently, the button moves based on the toggle.

Comment thread site/public/js/stat-page.js Outdated
const timestamps = $(this).data('timestamps');
const thread_ids = $(this).data('thread_id');
const thread_titles = $(this).data('thread_titles');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace.

@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Apr 7, 2026
@not-so-shubh

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot added the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label Apr 26, 2026
@not-so-shubh
not-so-shubh requested a review from JManion32 April 28, 2026 21:42
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Apr 28, 2026
@JManion32 JManion32 removed the Abandoned PR - Needs New Owner No activity on PR for more than 2 weeks -- seeking new owner to complete label May 1, 2026
@codecov

codecov Bot commented May 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 21.67%. Comparing base (621d276) to head (52af748).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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           
Flag Coverage Δ
autograder 21.32% <ø> (ø)
js 2.02% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.73% <ø> (ø)
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 91.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JManion32 JManion32 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Headers now sort in the same way that other tables on the site do:
Image

Nice work!

@github-project-automation github-project-automation Bot moved this from In Review to Awaiting Maintainer Review in Submitty Development May 1, 2026
@bmcutler
bmcutler merged commit 622f781 into Submitty:main May 1, 2026
14 of 24 checks passed
prestoncarman added a commit that referenced this pull request May 21, 2026
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Forum stats headers render escaped HTML when sorting

5 participants