fix: resolve dark mode icon timing issue and fix mobile nav Surveys label#1054
fix: resolve dark mode icon timing issue and fix mobile nav Surveys label#1054Tanisha127 wants to merge 1 commit intoalphaonelabs:mainfrom
Conversation
👀 Peer Review RequiredHi @Tanisha127! This pull request does not yet have a peer review. Before this PR can be merged, please request a review from one of your peers:
Thank you for contributing! 🎉 |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: alphaonelabs/coderabbit/.coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughDark mode JavaScript logic is refactored to eliminate theme flash on page load by applying stored theme immediately, support both desktop and mobile theme toggle icons, and disable debug logging. The flow initializes theme before DOM loads, then updates icon elements after DOM is ready. ChangesDark Mode Flash Prevention and Icon Management
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~8 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚚 This Repository Is MovingHi @Tanisha127, thank you for your contribution! We are in the process of migrating most of the logic from this repository to our new repository: alphaonelabs/learn. What this means for your PRPlease do not merge or continue work here. Instead:
This PR has been automatically closed. Once you have opened your PR in the new repository, feel free to reference it here. Thank you for your understanding and continued support! 🙏 |
Problem
Two bugs were found in
web/templates/base.html:Bug 1 — Dark mode icon not found warning
The
updateDarkModeIcon()function was called before the DOM finished loading, causing this console warning on every page load : Warning: Dark mode icon element not foundThis happened because
initializeDarkMode()was called immediately in the script, before the icon element existed in the DOM.Bug 2 — Mobile nav showed "Learning Requests" instead of "Surveys"
The Surveys link in the mobile COMMUNITY section was incorrectly labeled as "Learning Requests", causing user confusion.
Fix
updateDarkModeIcon()to also sync the mobile icon (darkModeIconMobile)Testing
Summary
This PR resolves two dark mode and mobile navigation issues in the base template:
Issues Fixed
Dark Mode Icon Timing Issue: Separated the application of the dark class (runs immediately in the
<head>to prevent flash) from the icon update logic (deferred untilDOMContentLoaded). This eliminates the console warning "Warning: Dark mode icon element not found" that previously occurred whenupdateDarkModeIcon()was called before the DOM finished loading.Mobile Navigation Label Bug: Fixed the Surveys link in the mobile COMMUNITY section, which was incorrectly labeled as "Learning Requests".
Key Changes
DEBUGconstant tofalseto suppress development logs in production.updateDarkModeIcon()function to sync both desktop (darkModeIcon) and mobile (darkModeIconMobile) dark mode toggle icons.DOMContentLoadedevent listenerVerification
Dark mode toggle now works correctly on both desktop and mobile without console warnings, and mobile navigation labels are accurate.