Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Console Error: Missing target element "mobileLogo" for "auto-theme-switcher" controller when user has a custom OP Logo (#20307)

Kabiru Mwenja11a5da7c1748
diff --git a/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts b/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
index 55b08efd8d9..4f369074c73 100644
--- a/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
+++ b/frontend/src/stimulus/controllers/auto-theme-switcher.controller.ts
@@ -45,6 +45,7 @@ export default class AutoThemeSwitcher extends Controller {
declare readonly mobileLogoTarget:HTMLLinkElement;
declare readonly desktopLightHighContrastLogoClass:string;
declare readonly mobileWhiteLogoClass:string;
+ declare readonly hasMobileLogoTarget:boolean;
connect() {
if (this.modeValue !== 'sync_with_os') return;
@@ -74,7 +75,11 @@ export default class AutoThemeSwitcher extends Controller {
private updateOpLogoContrast():void {
const prefersSystemLightHighContrast = window.OpenProject.theme.prefersSystemLightHighContrast();
+
this.desktopLogoTarget.classList.toggle(this.desktopLightHighContrastLogoClass, prefersSystemLightHighContrast);
- this.mobileLogoTarget.classList.toggle(this.mobileWhiteLogoClass, !prefersSystemLightHighContrast);
+ // Custom logos are not supported on mobile
+ if (this.hasMobileLogoTarget) {
+ this.mobileLogoTarget.classList.toggle(this.mobileWhiteLogoClass, !prefersSystemLightHighContrast);
+ }
}
}