Skip to content

fix: improve theme toggle functionality in ThemeContext#75

Closed
HRISHIKESH-hackoff wants to merge 1 commit intoNsanjayboruds:mainfrom
HRISHIKESH-hackoff:HRISHIKESH-hackoff-patch-1
Closed

fix: improve theme toggle functionality in ThemeContext#75
HRISHIKESH-hackoff wants to merge 1 commit intoNsanjayboruds:mainfrom
HRISHIKESH-hackoff:HRISHIKESH-hackoff-patch-1

Conversation

@HRISHIKESH-hackoff
Copy link
Copy Markdown

Fixes

Closes #32 - Light/Dark mode toggle not working

Description

This PR improves the theme toggle functionality in the ThemeContext to fix the issue where the dark mode toggle was not working properly.

Changes

  • Replaced classList.toggle() with explicit classList.add() and classList.remove() methods for more reliable DOM manipulation
  • Added useCallback hook for the toggleTheme function to prevent unnecessary re-renders and improve performance
  • Updated setTheme to use a callback function ensuring synchronous DOM updates with state changes
  • Improved initial theme setup to use explicit class methods instead of toggle
  • Fixed potential race conditions in theme updates

Testing

The theme toggle should now:

  1. Immediately switch between light and dark modes when the toggle button is clicked
  2. Persist the selected theme in localStorage
  3. Respect system preferences on initial load
  4. Apply theme changes correctly to the DOM

@akshay0611
Copy link
Copy Markdown
Collaborator

Hi @HRISHIKESH-hackoff,

Appreciate you raising the PR #75 – fix: improve theme toggle functionality in ThemeContext. Good initiative on addressing the theme toggle behavior 👍

However, the related issue [Bug]: Light/Dark mode toggle not working #32 is currently assigned to @soumojit-D48.

For now, let’s allow the assigned contributor to work on it. If there’s no progress from their side, you can comment on #32 requesting assignment. Once I reassign it to you, you can then link your PR (#75) to that issue properly.

Thanks again for being proactive - keep that momentum going.

Akshay Kumar
https://www.linkedin.com/in/akshaykumar0611/

@akshay0611
Copy link
Copy Markdown
Collaborator

Closing as Fixed ✅
This issue has been resolved in PR #96 which implements dark mode as the default theme and fixes the theme toggle functionality.

The fix includes:

Proper dark/light mode toggle implementation
localStorage persistence for theme preference
Consistent styling across all components
The feature is now working correctly. Closing this issue.

@akshay0611 akshay0611 closed this Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Light/Dark mode toggle not working

2 participants