Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #3197415
Dark mode not enabling automatically
Closed

Comments

  •  2
    HOnza started the conversation

    I have enabled the dark mode switcher and set the "Auto Dark Mode" option to "By Operating System". But when I access the site it just ignores my operating system's mode and requires me to switch between light and dark modes manually. Is this a bug or am I doing something incorrectly? I am trying it with Safari and Chrome on macOS 12.6.1.

  •  2,610
    PenciDesign replied

    Hi,

    This is a small issue with the JS code, I'll check and fix it in the future theme update.

    Regards,
    PenciDesign.


  •  2
    HOnza replied

    OK, thanks. Any clue when that might be? I.e. January? Or later?

  •  2,610
    PenciDesign replied

    Hi,

    The update will be available in January.

    Regards,
    PenciDesign.


  •  2
    HOnza replied

    Hello, any update on this? I have updated to the latest version but the dark mode still does not seem to be in sync with the client OS settings...

  •   PenciDesign replied privately
  •   HOnza replied privately
  •  2,610
    PenciDesign replied

    Hi,

    I've updated your site, please clear all the browser cache then check again.

    Regards,
    PenciDesign.


  •   HOnza replied privately
  •  2,610
    PenciDesign replied

    Hi,

    I've re-updated this file on your site:

    soledad/js/darkmode-loading.js

    Please check.

    Regards,
    PenciDesign.


  •   HOnza replied privately
  •  2
    HOnza replied

    I am trying to debug the javascript and here's what I have found out so far:

    On the first line there was a hard-coded setting of the cookie to dark. I assume it might be your temporary change in an attempt to debug the script. So I commented it out.

    Then I saw the script relies on the penci_dark variable, so I tried to check its contents using the JavaScript console and it always seems to return {auto_by: "1", darktheme: ""} regardless of how I configure it in the Customizer. I tried switching the auto dark mode there between Disabled, Operating System and User Time, no impact. Even if I deleted caches.

  •  2
    HOnza replied

    So I have modified the darkmode-loading.js file a bit and came up with a version that behaves almost as desired.

    I disabled storing the mode to cookie in this file because user only expects the mode to be fixed when they switch it manually. So if the mode is switched automatically based on the OS settings, it should not be saved to cookie.

    I also hard-coded the autoby to 'os' because penci_dark.auto_by does not seem to reflect the settings. I consider this as a temporary workaround and will appreciate you finding out why the penci_dark.auto_by does not contain 'os' event though I have set it so in the Customizer.

    What does not work but I would consider it a current limitation of your implementation rather than a bug, is that when my OS switches from light to dark mode and vice versa, the website does not switch automatically until I reload it or go to another page/article. I am not sure if there is a trigger for it (which I would prefer) or if that would require some kind of timer polling for the OS mode every second or so (which I would like to avoid as I hate polling as a bad practice in general).

  •  2
    HOnza replied

    OK, one last update from my side - I have added an event listener to mode switch.

    Now the website behaves the way I want, although I know it's a workaround and needs to be further cleaned up... I leave that to you now...

  •  2,610
    PenciDesign replied

    Hi,

    Thank you for your information.

    I'll research and update this feature soon.

    Regards,
    PenciDesign.