﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34740	Admin flashes dark/light depending on settings	Spencer Lowe	nobody	"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. "	Bug	closed	contrib.admin	4.2	Normal	duplicate			Unreviewed	0	0	0	0	0	1
