Skip to content

fix: theme toggle now applies theme on change (#2361) - #2434

Open
aaniya22 wants to merge 4 commits into
utksh1:mainfrom
aaniya22:fix/theme-toggle-not-switching-2361
Open

fix: theme toggle now applies theme on change (#2361)#2434
aaniya22 wants to merge 4 commits into
utksh1:mainfrom
aaniya22:fix/theme-toggle-not-switching-2361

Conversation

@aaniya22

@aaniya22 aaniya22 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the non-functional theme toggle in the Settings panel. The "Visual_Spectrum" dropdown was only updating local component state (config.theme) and never called setTheme() from ThemeContext — so selecting Light/Dark had zero effect until (and even after) clicking "Commit_Engine_Changes." The dropdown's onChange now calls setTheme() immediately, so the theme context and <html> class update as soon as the user picks a value.

Also added a .theme-light CSS override block in index.css (previously the class was toggled on <html> but no light-theme styles existed for the core design tokens like --bg-primary, --text-primary, etc., so even a working toggle had no visible effect on token-driven elements).

Known limitation (out of scope for this PR): Several pages, including Settings itself, use hardcoded Tailwind color classes (e.g. bg-charcoal-dark, text-silver) defined as static hex values in tailwind.config.js, rather than the CSS variable tokens. These don't respond to the theme toggle at all. Fully wiring light-mode support across the app would require rewriting these Tailwind classes to reference CSS variables across many files — a much larger change than this bug fix. Flagging this for a separate issue/PR.

Related Issues

Fixes #2361

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Ran npm run dev, went to Settings → Visual_Spectrum, changed the dropdown from Dark to Light and confirmed setTheme() fires immediately (verified via the sidebar toggle switching icon/state, and localStorage['secuscan-theme'] updating). Confirmed the .theme-light class is applied to <html> and that pages using CSS-variable-driven styles respond correctly. Tested in Chrome.

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: replacing the existing theme control removes the system-preference indicator and the reset-to-system behavior. Preserve those existing settings workflows while fixing the theme application, and add a regression test that changing the select updates the document theme and that system-controlled mode still works.

@utksh1 utksh1 added area:frontend Frontend React/UI work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:bug Bug fix work category bonus label labels Aug 4, 2026
@aaniya22

aaniya22 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Request changes: replacing the existing theme control removes the system-preference indicator and the reset-to-system behavior. Preserve those existing settings workflows while fixing the theme application, and add a regression test that changing the select updates the document theme and that system-controlled mode still works.

Fixed: ENGINE_RESET now clears the saved theme override and re-derives from OS preference (prefers-color-scheme) instead of leaving the previously-applied theme stale — this restores reset-to-system behavior. Added regression tests covering: theme applies immediately on select (the original #2361 fix), and ENGINE_RESET correctly restores system-controlled theme.

One thing I want to confirm — I didn't find a literal "system-preference indicator" UI element in Settings.tsx before this PR (no badge/label showing "currently following system"). If you meant something specific I might be missing, let me know and I'll add it; otherwise I've interpreted this as ensuring Reset genuinely re-syncs to OS preference rather than just cosmetically defaulting to "dark.

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

Labels

area:frontend Frontend React/UI work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:bug Bug fix work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Light/Dark Theme Toggle in Settings Panel Does Not Switch Themes

2 participants