diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php index 3cb2244b2c..acd09ca28f 100644 --- a/resources/views/layouts/base.blade.php +++ b/resources/views/layouts/base.blade.php @@ -303,13 +303,23 @@ }, }); - document.addEventListener('livewire:navigated', window.applyStoredTheme); + // wire:navigate copies the server attributes over the live ones, which removes + // the theme class and colors. Apply them again in the same task as the swap, before + // the browser can paint the new page (livewire:navigated can run after a paint). + document.addEventListener('livewire:navigating', (event) => event.detail.onSwap(window.applyStoredTheme)); window.applyStoredTheme(); })(); +