bui-themer: extract mui theme and then unmount theme provider

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-09-13 16:32:07 +02:00
parent 09e65c6266
commit d5c170eaf4
2 changed files with 49 additions and 31 deletions
@@ -74,12 +74,22 @@ export function UnifiedThemeProvider(
const themeName = 'backstage';
useEffect(() => {
const oldMode = document.body.getAttribute('data-theme-mode');
const oldName = document.body.getAttribute('data-theme-name');
document.body.setAttribute('data-theme-mode', themeMode);
document.body.setAttribute('data-theme-name', themeName);
return () => {
document.body.removeAttribute('data-theme-mode');
document.body.removeAttribute('data-theme-name');
if (oldMode) {
document.body.setAttribute('data-theme-mode', oldMode);
} else {
document.body.removeAttribute('data-theme-mode');
}
if (oldName) {
document.body.setAttribute('data-theme-name', oldName);
} else {
document.body.removeAttribute('data-theme-name');
}
};
}, [themeMode, themeName]);