netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Switch between dark/light mode doesn't take effect until user logs out and back in

Open jhammond-git opened this issue 10 months ago • 5 comments

Deployment Type

Self-hosted

NetBox Version

v4.0-beta1

Python Version

3.10

Steps to Reproduce

  1. Log in as a user.
  2. Click on the User menu in the top right
  3. Click Preferences
  4. Change color mode, and click Save at the bottom

Expected Behavior

Color mode changes as soon as Save is clicked and the page refreshes to the new mode.

Observed Behavior

Color mode doesn't change until user logs out of Netbox and back in.

jhammond-git avatar Apr 04 '24 19:04 jhammond-git

I went back to my production (3.7.4) and discovered it does the same in the Preferences menu, but also found the menu item for light/dark mode switch which takes effect immediately. That led me to the button which I noticed in beta that has the same function, but I didn't realize it was a button before.

Having said all that, I don't see why the preference can't change mode on Save, but I can also see why that wouldn't be a reasonable use of development time.

jhammond-git avatar Apr 04 '24 22:04 jhammond-git

The first time I tried to reproduce this issue (going from dark to light), it behaved as expected. Each subsequent time I was able to reproduce it consistently regardless of which direction the color mode was going.

jeffgdotorg avatar Apr 08 '24 13:04 jeffgdotorg

When the color mode is changed in User Preferences, you must log out and log in again for the changes to be applied. On the other hand, if you select "Dark" or "Light" on Preferences, the change is applied at the same time.

If you want to apply the changes as soon as the color mode changes, please assign this ticket to me.

Julio-Oliveira-Encora avatar Apr 09 '24 18:04 Julio-Oliveira-Encora

The root issue is that the user preference is stored on the backend, whereas the live toggle (the button at top right) saves its setting in local storage. So we can end up with a conflicting state where the user's preference indicates dark mode but local storage indicates light mode, or vice versa.

Honestly it feels like overkill to track light/dark mode as a preference anyway. I can easily see this being device- or time-dependent, and the live toggle makes much more sense IMO. Maybe we should just ditch the stored preference altogether.

jeremystretch avatar Apr 22 '24 18:04 jeremystretch

Honestly it feels like overkill to track light/dark mode as a preference anyway. I can easily see this being device- or time-dependent, and the live toggle makes much more sense IMO. Maybe we should just ditch the stored preference altogether.

The one arguement I could see is that if you move to new devices frequently, however I think that is a corner case and not the norm so we might not even care about it.

DanSheps avatar Apr 22 '24 22:04 DanSheps