Dark mode status not remembered

Created on 3 November 2024, about 2 months ago

Problem/Motivation

I love the module, and the dark mode changeover effect looks great.

However, when I have selected dark mode, it always reverts to light mode on the next page load.

I can see "darkmode" set to "true" in localstorage, and if I delete this key it reverts to the browser default.

Also, if the browser default is set to dark mode, and dark mode hasn't been explicitly set, then it will correctly select dark mode on each page load.

However, once dark mode has been explicitly selected, it always loads in light mode.

Steps to reproduce

  1. Ensure the browsers build in dark mode is selected and Darkmode JS module is enabled and the block active
  2. Browse several pages and note that they load in dark mode
  3. Use the Darkmode JS switcher to explicitly select dark mode
  4. Navigate to another page and verify that it doesn't show in dark mode

Proposed resolution

I'm hoping that I've missed something in setup, or that it's an easy fix.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @lostcarpark
  • 🇮🇪Ireland lostcarpark

    Update...

    It seems to be behaving itself now.

    I don't think anything on the site has changed apart from adding more content, and probably clearing cache a few times (but I had cleared cache when it wasn't behaving, and it didn't seem to make any difference.

    I suggest keeping the issue open a few days to see if it occurs again, but if it doesn't, I'm happy to close it.

  • 🇺🇦Ukraine bobi-mel

    Ok. Let us know if everything works as expected

  • I am experiencing the same issue. It works great once enabled, but when I go to a different page it resets back to light mode. I am not sure why this is happening at all. I just installed the module and followed the instructions exactly. Any help is apprecited!

  • I am also experiencing an issue where dark mode is enabled by default on first page load for some users, but the icon indicates that dark mode is not enabled.
    Status of dark mode is also not remembered in those cases.

  • I got this cleared up. This was related to the options in the dark mode settings.

    I did not have the cookie option enabled and didn't initially realize the effect of the button.

    I also did not realize my OS was set to dark mode, so I thought it was an error when opening up a browser and seeing dark mode unintentionally.

    I would recommend some help text on the settings page to describe the features of setting the cookie and Matching the OS theme.

  • 🇮🇪Ireland lostcarpark

    Got to agree that improving the description for the cookie option on the settings form would be really helpful.

Production build 0.71.5 2024