Skip to content

Commit 647c7d7

Browse files
committed
Fix themeing bug with Firefox where "disabled" ignored
A bug in firefox means "disabled" isn't honoured when set in the HTML. Doing `a.disabled = false` does work however, and Chrome also appears to honour this.
1 parent aa54032 commit 647c7d7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/vector/index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ async function loadApp() {
263263
} catch (e) {
264264
configError = e;
265265
}
266-
266+
267267
// XXX: We call this twice, once here and once in MatrixChat as a prop. We call it here to ensure
268-
// granular settings are loaded correctly and to avoid duplicating the override logic for the theme.
268+
// granular settings are loaded correctly and to avoid duplicating the override logic for the theme.
269269
SdkConfig.put(configJson);
270270

271271
// don't try to redirect to the native apps if we're
@@ -313,17 +313,26 @@ async function loadApp() {
313313
if (match) {
314314
if (match[1] === theme) {
315315
// remove the disabled flag off the stylesheet
316-
a.removeAttribute("disabled");
316+
317+
// Firefox requires setting the attribute to false, so do
318+
// that instead of removing it. Related:
319+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1281135
320+
a.disabled = false;
317321

318322
// in case the Tinter.tint() in MatrixChat fires before the
319323
// CSS has actually loaded (which in practice happens)...
320324

321325
// FIXME: we should probably block loading the app or even
322326
// showing a spinner until the theme is loaded, to avoid
323327
// flashes of unstyled content.
324-
a.onload = () => {
328+
a.onload = () => {
325329
Tinter.setTheme(theme);
326330
};
331+
} else {
332+
// Firefox requires this to not be done via `setAttribute`
333+
// or via HTML.
334+
// https://bugzilla.mozilla.org/show_bug.cgi?id=1281135
335+
a.disabled = true;
327336
}
328337
}
329338
}

0 commit comments

Comments
 (0)