Skip to content

[BUG] Theme Toggle Doesn't Persist on Page Refresh #1506

@ishani-1910

Description

@ishani-1910

Summary

When a user switches between Light and Dark mode using the ThemeToggle component, the selected theme is lost on page refresh. The app always defaults back to the system default instead of remembering the user's choice.

Description

The ThemeToggle.tsx component reads from ThemeContext and toggles the theme, but it does not persist the user's preference to localStorage. On every page refresh, the component re-initializes without checking for a saved preference. The theme selection should survive browser refreshes.

Steps to Reproduce

  1. Open the DevTrack dashboard at http://localhost:3000/dashboard
  2. Click the Light / Dark toggle button in the header
  3. Confirm the theme switches (e.g., from Light to Dark)
  4. Refresh the page (F5 or Ctrl+R)
  5. Observe: the theme resets to the default instead of the previously chosen theme

Expected Behavior

After toggling the theme, the user's choice should be saved in localStorage. On page reload, ThemeContext should read this saved value and apply the correct theme without any flash or reset.

Actual Behavior

The theme resets to the default theme on every page reload. The user's manually selected theme is not remembered.

Environment

  • Local Development
  • Staging
  • Production
  • Other

System Information (Optional)

  • OS: Any
  • Browser: Chrome 120+, Firefox 120+
  • Node.js: 18+
  • Component: src/components/ThemeToggle.tsx, src/components/ThemeContext.tsx

Hello I am a GSSOC'26 COntributor and would love to work on this issue. Please assign it to me under gssoc'26
/assign gssoc

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomersgssoc26GSSoC 2026 contributiongssoc:assignedGSSoC: Issue assigned to a contributorlevel:beginnerGSSoC: Beginner difficulty (20 pts)needs-triageNeeds maintainer triagetype:bugGSSoC type bonus: bug fix

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions