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

don't throw exception on invalid query selector

Markus Kahl4c3efeaa0a42
diff --git a/frontend/src/app/globals/global-listeners.ts b/frontend/src/app/globals/global-listeners.ts
index 31cd4b726ec..5c2d059add2 100644
--- a/frontend/src/app/globals/global-listeners.ts
+++ b/frontend/src/app/globals/global-listeners.ts
@@ -54,8 +54,15 @@ import {registerRequestForConfirmation} from "core-app/globals/global-listeners/
// Jump to the element given by location.hash, if present
const hash = window.location.hash;
if (hash && hash.startsWith('#')) {
- const el = document.querySelector(hash);
- el && el.scrollIntoView();
+ try {
+ const el = document.querySelector(hash);
+ el && el.scrollIntoView();
+ } catch (e) {
+ // This is very likely an invalid selector such as a Google Analytics tag.
+ // We can safely ignore this and just not scroll in this case.
+ // Still log the error so one can confirm the reason there is no scrolling.
+ console.log("Could not scroll to given location hash: " + hash + " ( " + e.message + ")");
+ }
}
// Global submitting hook,