Currently, I think that once a user has turned dark mode on, turning dark mode off will not persist between refreshes of the site.
Recreation:
Start with the default theme of the site.
Turn dark mode on.
Refresh and turn the dark mode off. The site will go back to light mode (until we refresh in the next step)
Refresh. The page will be using dark mode even though we turned it off in the previous step.
Fix:
localStorage.getItem('darkMode') returns a String, so as long as getItem returned any non-empty string (either "true" or "false"), then dark mode was getting turned on. So, we now compare with the String "true".
Currently, I think that once a user has turned dark mode on, turning dark mode off will not persist between refreshes of the site.
Recreation:
Fix:
localStorage.getItem('darkMode')
returns a String, so as long asgetItem
returned any non-empty string (either"true"
or"false"
), then dark mode was getting turned on. So, we now compare with the String"true"
.