@samitouri / QOS-React-1 / commits / b1a6f03f8a

[DevTools] Rerender when the browser theme changes (#33992)

When the browser theme changes, we don't immediately rerender the UI so we don't pick up the new theme if the React devtools are set to auto. This picks up the change immediately.

Sebastian Markbåge committed Jul 25, 2025 at 10:19 UTC b1a6f03f8af2b5ce5ee466d89d218606089c0395
1 file changed +13
packages/react-devtools-extensions/src/main/index.js
+13
@@ -530,3 +530,16 @@ if (__IS_FIREFOX__) {
530 connectExtensionPort();
531
532 mountReactDevToolsWhenReactHasLoaded();
533 +
534 +function onThemeChanged(themeName) {
535 + // Rerender with the new theme
536 + render();
537 +}
538 +
539 +if (chrome.devtools.panels.setThemeChangeHandler) {
540 + // Chrome
541 + chrome.devtools.panels.setThemeChangeHandler(onThemeChanged);
542 +} else if (chrome.devtools.panels.onThemeChanged) {
543 + // Firefox
544 + chrome.devtools.panels.onThemeChanged.addListener(onThemeChanged);
545 +}