Fix setting default color mode in dev mode (#4616)

* Fix setting default color mode in dev mode

Without this, the last_compiled_timestamp local storage never gets set because
it's always `null` until it gets set.

* test_client_storage: also pop `theme` key from next-themes
This commit is contained in:
Masen Furer 2025-01-22 15:30:11 -08:00 committed by GitHub
parent 1ca36fa6c1
commit 6d314d10c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View File

@ -16,10 +16,7 @@ export default function RadixThemesColorModeProvider({ children }) {
if (isDevMode) {
const lastCompiledTimeInLocalStorage =
localStorage.getItem("last_compiled_time");
if (
lastCompiledTimeInLocalStorage &&
lastCompiledTimeInLocalStorage !== lastCompiledTimeStamp
) {
if (lastCompiledTimeInLocalStorage !== lastCompiledTimeStamp) {
// on app startup, make sure the application color mode is persisted correctly.
setTheme(defaultColorMode);
localStorage.setItem("last_compiled_time", lastCompiledTimeStamp);

View File

@ -321,6 +321,7 @@ async def test_client_side_state(
assert not driver.get_cookies()
local_storage_items = local_storage.items()
local_storage_items.pop("last_compiled_time", None)
local_storage_items.pop("theme", None)
assert not local_storage_items
# set some cookies and local storage values
@ -436,6 +437,7 @@ async def test_client_side_state(
local_storage_items = local_storage.items()
local_storage_items.pop("last_compiled_time", None)
local_storage_items.pop("theme", None)
assert local_storage_items.pop(f"{sub_state_name}.l1") == "l1 value"
assert local_storage_items.pop(f"{sub_state_name}.l2") == "l2 value"
assert local_storage_items.pop("l3") == "l3 value"