[Django] #34741: Admin flashes dark/light depending on settings

28 views
Skip to first unread message

Django

unread,
Jul 25, 2023, 4:39:38 PM7/25/23
to django-...@googlegroups.com
#34741: Admin flashes dark/light depending on settings
-----------------------------------------+------------------------
Reporter: nerdbaggy | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-----------------------------------------+------------------------
When the user has their prefers-color-scheme set to dark, and then they
force the Django Admin to light mode it causes the page to flash dark then
light momentarily. (See attached video). This test video is on a fresh
install with no extra apps installed.

Why is this happening you may ask. The JS code that forces the theme to
dark/light is set to run on page load.
https://github.com/django/django/blob/main/django/contrib/admin/static/admin/js/theme.js#L3

Because of this the full page loads for a moment with the dark theme, then
the page load event happens and then the js code changes the theme to
light.
The initTheme() and setTheme() functions don't really need to be inside
the event page load. Nothing in those 2 functions are doing anything that
require the entire page to be loaded. It is just using local storage and
modify the dataset on the html div. So those functions could be moved
outside of the on load event. I don't mind making the merge request for it
just wanted to get opinions on it.

--
Ticket URL: <https://code.djangoproject.com/ticket/34741>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 25, 2023, 4:40:12 PM7/25/23
to django-...@googlegroups.com
#34741: Admin flashes dark/light depending on settings
-------------------------------+--------------------------------------
Reporter: nerdbaggy | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 4.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+--------------------------------------
Changes (by nerdbaggy):

* status: new => closed
* resolution: => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/34741#comment:1>

Django

unread,
Jul 25, 2023, 4:48:39 PM7/25/23
to django-...@googlegroups.com
#34741: Admin flashes dark/light depending on settings
-------------------------------+--------------------------------------
Reporter: nerdbaggy | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 4.2
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* resolution: invalid => duplicate


Comment:

Duplicate of #34740.

--
Ticket URL: <https://code.djangoproject.com/ticket/34741#comment:2>

Reply all
Reply to author
Forward
0 new messages