Skip to content

Conversation

arkirchner
Copy link
Contributor

The migration event needs to be used to set the event listeners for the theme select.

The migration event needs to be used to set the event listeners
for the theme select.
@arkirchner arkirchner self-assigned this Jul 28, 2025
@arkirchner arkirchner added the bug label Jul 28, 2025
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.08%. Comparing base (ea29353) to head (e93b68b).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3040   +/-   ##
=======================================
  Coverage   70.08%   70.08%           
=======================================
  Files         215      215           
  Lines        6850     6850           
=======================================
  Hits         4801     4801           
  Misses       2049     2049           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arkirchner arkirchner requested a review from kkoehn July 29, 2025 14:35
@arkirchner arkirchner merged commit 97de3f3 into main Jul 30, 2025
15 checks passed
@arkirchner arkirchner deleted the ak/fix-theme-select branch July 30, 2025 07:19
@MrSerth
Copy link
Member

MrSerth commented Jul 30, 2025

@arkirchner I have major concerns with this change. Can you please provide some reasoning why you changed that, which bug you're fixing therewith, and what your long-term strategy is (without using the migration event)?

From my point of view, the event listener is not bound to any Sprockets code; therefore, I don't see any necessity to wait longer for the delayed event. Furthermore, the delayed event will cause some extended, visible "white flashes" when navigating in dark mode.

@kkoehn
Copy link
Contributor

kkoehn commented Aug 4, 2025

I can't speak for Armin but for me (locally) the appearance selector didn't always work and sometimes needed a reload. I have not seen that (yet?) with this fix. I also have not seen any of the flashes you mentioned in dark mode.

@arkirchner
Copy link
Contributor Author

Sorry I have overlooked this. I tried the theme change (production and local), and it never worked for me and my coworkers. It worked with the migration event. I did not notice the delay.

I am migrating the Sprockets code here: #3021

@MrSerth
Copy link
Member

MrSerth commented Aug 5, 2025

Thanks for your comments. I've spent some additional time debugging, and it seems like some race condition in the previous version was, indeed, causing the buttons to be non-functional. Sorry for that, my fault.

Since the code has been moved to webpack already, I think the event can be changed back to turbo:load, and this seems to work constantly in my testing.

The flashing might be visible when changing from one page to another, when the included packs change. For example, when navigating from /exercises to /exercises/1 (because we add the highlight.js bundle to the Exercise#show action). In my experience and my measurements, the flashing is extended when waiting for the turbo-migration:load rather than the turbo:load.

Long story short: Since the code has been moved to webpack, can we go back to turbo:load today?

@arkirchner
Copy link
Contributor Author

arkirchner commented Aug 6, 2025

Long story short: Since the code has been moved to webpack, can we go back to turbo:load today?

I tried, but I got an error. Now that the file is moved it will execute (some times) before base js is present. I am trying to move base JS as well. Please give me some time to see if there are no other issues when moving base js.

My mistake! Not necessary!

arkirchner added a commit that referenced this pull request Aug 6, 2025
The `tubo:load` event is faster than the migration event. The color changing requires no sprocket code and can be controlled without the migration event. This removes the flickering in dark mode when navigating the page.

This change is possible because the theme-changing logic was moved to Webpacker and loads before Sprockets. Please see #3025

Related to #3040
@MrSerth
Copy link
Member

MrSerth commented Aug 6, 2025

Alright, great! Thanks for the new PR 👍

arkirchner added a commit that referenced this pull request Aug 7, 2025
The `tubo:load` event is faster than the migration event. The color changing requires no sprocket code and can be controlled without the migration event. This removes the flickering in dark mode when navigating the page.

This change is possible because the theme-changing logic was moved to Webpacker and loads before Sprockets. Please see #3025

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants