Conversation
theme-switcher.js ran in <head> before #admin-navbar existed in the DOM, so the initial navbar class switch (navbar-dark/bg-dark ↔ navbar-light/bg-light) silently failed. Only the MatchMedia change listener worked — meaning the navbar only got correct classes after a live OS theme toggle, never on initial page load. Split into: set data-bs-theme immediately (avoids flash), apply navbar classes deferred via DOMContentLoaded, and the change listener now calls the unified applyTheme() for both.
|
📝 Manual Update Required? It looks like you've modified core logic. Please check if the user manual needs a refresh! @marpisco |
Expose window.__applyNavbarTheme from theme-switcher.js and call it via an inline <script> placed immediately after the navbar HTML. This runs synchronously before paint, eliminating the visible flash of the wrong navbar theme on initial load. DOMContentLoaded listener retained as a fallback; MatchMedia change listener still handles live OS theme toggles.
|
📝 Manual Update Required? It looks like you've modified core logic. Please check if the user manual needs a refresh! @marpisco |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
theme-switcher.jswas loaded in<head>, before#admin-navbarexisted in the DOM. The initialapplyTheme()call silently failed to switch navbar classes (navbar-dark/bg-dark↔navbar-light/bg-light).Only the
MatchMediachange listener worked — the navbar only got correct theme classes after a live OS theme toggle, never on initial page load or after navigating to another admin page.What changed
data-bs-themeis still set immediately in<head>(avoids flash of wrong theme)window.__applyNavbarThemeexposed bytheme-switcher.js<script>placed immediately after the navbar HTML calls it synchronously — runs before paint, no flashDOMContentLoadedlistener retained as fallbackMatchMediachange listener handles live OS theme togglesCloses #157