Fix background-image: url(null) for backdrop filter

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2020-10-14 11:41:24 +01:00
parent dce047e25c
commit efad42439e
2 changed files with 6 additions and 2 deletions

View File

@ -6,7 +6,7 @@
@supports (backdrop-filter: none) {
.mx_LeftPanel {
background-image: var(--avatar-url);
background-image: var(--avatar-url, unset);
background-repeat: no-repeat;
background-size: cover;
background-position: left top;

View File

@ -119,8 +119,12 @@ export default class LeftPanel extends React.Component<IProps, IState> {
if (settingBgMxc) {
avatarUrl = MatrixClientPeg.get().mxcUrlToHttp(settingBgMxc, avatarSize, avatarSize);
}
const avatarUrlProp = `url(${avatarUrl})`;
if (document.body.style.getPropertyValue("--avatar-url") !== avatarUrlProp) {
const existingValue = document.body.style.getPropertyValue("--avatar-url");
if (!avatarUrl && existingValue) {
document.body.style.removeProperty("--avatar-url");
} else if (avatarUrl && existingValue !== avatarUrlProp) {
document.body.style.setProperty("--avatar-url", avatarUrlProp);
}
};