From 14b065cf5f1221dee59f2c2a32a5d2347a2c525e Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Wed, 29 Sep 2021 17:44:28 -0700 Subject: [PATCH] Fixes #7373: Improve handling of mismatched server, client, and browser color-mode preferences --- docs/release-notes/version-3.0.md | 4 ++ netbox/templates/base/base.html | 89 ++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 32 deletions(-) diff --git a/docs/release-notes/version-3.0.md b/docs/release-notes/version-3.0.md index d25c4c441..140edba09 100644 --- a/docs/release-notes/version-3.0.md +++ b/docs/release-notes/version-3.0.md @@ -2,6 +2,10 @@ ## v3.0.5 (FUTURE) +### Bug Fixes + +* [#7373](https://github.com/netbox-community/netbox/issues/7373) - Fix flashing when server, client, and browser color-mode preferences are mismatched + --- ## v3.0.4 (2021-09-29) diff --git a/netbox/templates/base/base.html b/netbox/templates/base/base.html index 71172e901..78dc2b744 100644 --- a/netbox/templates/base/base.html +++ b/netbox/templates/base/base.html @@ -6,11 +6,15 @@ lang="en" data-netbox-url-name="{{ request.resolver_match.url_name }}" data-netbox-base-path="{{ settings.BASE_PATH }}" - {% if preferences|get_key:'ui.colormode' == 'dark'%} - data-netbox-color-mode="dark" - {% else %} - data-netbox-color-mode="light" - {% endif %} + {% with preferences|get_key:'ui.colormode' as color_mode %} + {% if color_mode == 'dark'%} + data-netbox-color-mode="dark" + {% elif color_mode == 'light' %} + data-netbox-color-mode="light" + {% else %} + data-netbox-color-mode="unset" + {% endif %} + {% endwith %} > @@ -23,34 +27,55 @@ {% block title %}Home{% endblock %} | NetBox {# Static resources #}