question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Persistence of theming preferences

See original GitHub issue

Is your feature request related to a problem? Please describe. This is not really an issue, but more like a new feature. Today we have 2 options with the storage of theming preferences: session or none. The first one is the default, the second one can be achieved following: https://marmelab.com/react-admin/Store.html#transient-store

But I believe it would be really useful that the theme selected with ToggleThemeButton would not be flushed during a logout. Indeed, like most websites if I set my theme to dark mode then I want it dark next time I go on my website.

Describe the solution you’d like I dug in the source code but did not find an option to change that myself (PR or existing param). I don’t know how other localStorage values (such as language) are managed in term of resetting, but I believe a global option in Admin component (such as the existing store param) or an attribute of the Logout component could do the trick. The default one could be the session as it is (although I personally don’t like it), and you would also have none and browser (or whatever).

Describe alternatives you’ve considered This cache persistence could also be a param of ToggleThemeButton, but again even if I don’t use the ToggleLanguageButton component I believe there would be to many components needing change (instead of 1 global one). Before using the ToggleThemeButton I was using a custom Settings page exactly as in the demo, so I was setting the localStorage values myself and never resetting it.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Masoodtcommented, Jun 28, 2022

Plus with the current behavior, the login page is always in default language. So if you set the preferred language to french, then you will still have it in english. I feel like my suggestion could be the solution to have both the current behavior (if still wanted) and the one I’m looking for that seems pretty common.

hot fix:

import {Admin, localStorageStore,} from "react-admin";
const customStore = localStorageStore("1");
  customStore.reset = () => {
    console.log("resetting aborted");
  };
return (
<Admin
      store={customStore}
    >
<Admin>
1reaction
bladxcommented, Jun 29, 2022

Wow cheers, that works like a charm!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

wordpress/preferences-persistence | Block Editor Handbook
Persistence utilities for wordpress/preferences . Includes a persistence layer that saves data to WordPress user meta via the REST API.
Read more >
Persistent Theme Change in Flutter | Shared Preference
Persistent Theme of the flutter app after the restart also. We will do this using shared preferences and provider.
Read more >
How can I persist my theme settings in android app?
The theme changes in current activity(Settings Activity), but I have to restart the other background activities to apply the new theme.
Read more >
Persisting User Preferences & Control Values - Dash Plotly
Persistence is keyed to the combination of component id and this persistence value, so if this value changes you will see different persisted...
Read more >
12.5. Persisting locale and theme preferences via cookies JBoss ...
The locale selector, theme selector and timezone selector all support persistence of locale and theme preference to a cookie. Simply set the cookie-enabled ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found