Skip to content

Commit

Permalink
fix(theme.js): fix backdrop blur not appying sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
SunsetTechuila committed May 19, 2023
1 parent fbf0d85 commit f92b843
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,4 +572,33 @@
([uri]) => Spicetify.URI.isFolder(uri),
'edit'
).register();

// fix backdrop-filter for some flyouts and menus
// see https://github.com/nimsandu/spicetify-bloom/issues/220#issuecomment-1555071865
function bodyCallback(mutationsList) {
for (let i = 0; i < mutationsList.length; i += 1) {
if (mutationsList[i].addedNodes[0]?.id?.includes('tippy')) {
const tippy = mutationsList[i].addedNodes[0];
const body = document.querySelector('body');
if (tippy.parentNode != body) {
// inherit colors
tippy.classList.add('encore-dark-theme');
body.appendChild(tippy);
// trigger element postition correction
window.dispatchEvent(new Event('resize'));
}
}
}
}

waitForElement(['body'], () => {
const body = document.querySelector('body');
const bodyObserver = new MutationObserver(bodyCallback);
const bodyObserverConfig = {
attributes: false,
childList: true,
subtree: true,
};
bodyObserver.observe(body, bodyObserverConfig);
});
})();

0 comments on commit f92b843

Please sign in to comment.