From dc9957795e2b2a194ed02115f58ff00a7d7c5875 Mon Sep 17 00:00:00 2001 From: Armin Kirchner Date: Wed, 6 Aug 2025 10:35:38 +0200 Subject: [PATCH] fix: Faster theme loading to avoid flickering 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 --- app/javascript/sprocket-asset-import/color-mode-picker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/sprocket-asset-import/color-mode-picker.js b/app/javascript/sprocket-asset-import/color-mode-picker.js index 67b59f41b..e14e873c0 100644 --- a/app/javascript/sprocket-asset-import/color-mode-picker.js +++ b/app/javascript/sprocket-asset-import/color-mode-picker.js @@ -77,7 +77,7 @@ function showActiveTheme(theme, focus = false) { } } -$(document).on('turbo-migration:load', function() { +$(document).on('turbo:load', function() { setTheme(getPreferredTheme()) showActiveTheme(getPreferredTheme())