Skip to content

improve Assignment Progress responsiveness on Safari#2008

Open
barna-isaac wants to merge 2 commits intomainfrom
improvement/safari-assignment-progress-performance
Open

improve Assignment Progress responsiveness on Safari#2008
barna-isaac wants to merge 2 commits intomainfrom
improvement/safari-assignment-progress-performance

Conversation

@barna-isaac
Copy link
Contributor

@barna-isaac barna-isaac commented Mar 2, 2026

For a group with ~1000 members (for example: https://isaacscience.org/assignment_progress/550781), sorting by a question (eg: clicking column 3) takes over 30 seconds. After the improvement, it takes about 200ms (just like on Chrome). It seems that Safari really struggles with the &:has(.class) css selector, which selectively applies styles to a parent when any (potentially nested) children have .class.

I've moved this decision to the application logic, and assignment progress is now just as performant on Safari as it was in Chrome.

For a group with ~1000 members, sorting by a question (eg: clicking
column 3) takes over 30 seconds. After the improvement, it takes about
200ms (just like on Chrome). It seems that Safari really struggles with
the `&:has(.class)` css selector, which selectively applies styles
to a parent when any (potentially non-direct) children have `.class`.
I've moved this decision to the application logic, and assignment
progress is now just as performant on Safari as it was in Chrome.
@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 43.21%. Comparing base (0bf7d04) to head (6086cf9).
⚠️ Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
...pp/components/elements/quiz/QuizProgressCommon.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2008      +/-   ##
==========================================
+ Coverage   43.19%   43.21%   +0.02%     
==========================================
  Files         575      575              
  Lines       24746    24748       +2     
  Branches     8214     8187      -27     
==========================================
+ Hits        10690    10696       +6     
+ Misses      14007    13376     -631     
- Partials       49      676     +627     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@jacbn jacbn left a comment

Choose a reason for hiding this comment

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

Works nicely, thanks for looking into profiling on Safari. We can simplify the classes a little though!

{progress && progress.length > 0 ? <>
<div className={classNames("assignment-progress-table-wrapper border", {"rounded-3": isAda})} ref={scrollContainerRef}>
<table ref={tableRef} className="progress-table w-100">
<table ref={tableRef} className={classNames({['progress-table']: true, ['w-100']: true, ['has-selected']: questions.some((_, index) => index === selectedQuestionIndex)})}>
Copy link
Contributor

Choose a reason for hiding this comment

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

You can just put plain strings inside classNames, it has the same effect as {string: true}:

Suggested change
<table ref={tableRef} className={classNames({['progress-table']: true, ['w-100']: true, ['has-selected']: questions.some((_, index) => index === selectedQuestionIndex)})}>
<table ref={tableRef} className={classNames('progress-table w-100', {'has-selected': selectedQuestionIndex !== undefined})}>

(was there a reason we needed to check whether the index was in questions? if not, just a defined-ness check is enough)

Copy link
Contributor

@jacbn jacbn Mar 2, 2026

Choose a reason for hiding this comment

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

We can reduce the scope of the changes by keeping the .progress-table.has-selected SCSS inside a single parent. It's entirely nitpicky as the output is exactly the same, but good practice to minimise PR size. I've committed this separately as Git split your changes into too many to comment over –– but notice there are only two lines changed total now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants