- Issue created by @NicociN
- 🇫🇷France just_like_good_vibes PARIS
hello,
i agree this fix is usefull, when you use the modal to change colorScheme, it saves the preferences to local storage and this settings should be honored.
But, we have to be careful which javascript code is enforcing the selection of the user done in localStorage VS the default selection made in the drupal theme.the following code (minified here), is not working in every situation and should be updated to carefully apply the correct theme according to the order of preferences.
const e="system",t="dark",c="dark",o="data-fr-theme",a="data-fr-scheme",r=`:root[${o}], :root[${a}]`,m=()=>{document.documentElement.setAttribute(o,c),document.documentElement.style.colorScheme="dark"},n=()=>{window.matchMedia("(prefers-color-scheme: dark)").matches&&m()};(()=>{if(document.documentElement.matches(r)){const c=(()=>{try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}})()?localStorage.getItem("scheme"):"",o=document.documentElement.getAttribute(a);switch(!0){case c===t:m();break;case c===e:n();break;case o===t:m();break;case o===e:n()}}})();
Indeed, if in drupal theme settings, we select "dark mode", and if the user has selected "light mode" (saved in local storage), then dark mode wins, which is not what we want.
- 🇫🇷France just_like_good_vibes PARIS
please, when and if ready, could you please change the status of the issue to "Needs review" and assign it to me.
thank you :) - 🇫🇷France just_like_good_vibes PARIS
without answer from you, i will take a decision and merge.
-
just_like_good_vibes →
committed 01aaf206 on 1.0.x authored by
nicocin →
Issue #3476943 by nicocin: Theme switches back to default after a few...
-
just_like_good_vibes →
committed 01aaf206 on 1.0.x authored by
nicocin →
Automatically closed - issue fixed for 2 weeks with no activity.