Skip to content

Commit 0b8db59

Browse files
committed
dashboard - don't interfere with external links
1 parent a34e9d0 commit 0b8db59

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

news/changelog-1.6.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ All changes included in 1.6:
2828

2929
## `dashboard` Format
3030

31+
- ([#9411](https://github.com/quarto-dev/quarto-cli/issues/9411)): Fix issue with history navigation in dashboards and external links.
3132
- ([#10340](https://github.com/quarto-dev/quarto-cli/issues/10340)): Build card title correctly in the presence of equations and other markup.
3233

3334
## `html` Format

src/resources/formats/dashboard/quarto-dashboard.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,20 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
145145
const linkEls = document.querySelectorAll(
146146
".quarto-dashboard-content a:not(.nav-link)"
147147
);
148+
const currentUrl = new URL(window.location.href);
148149
for (const linkEl of linkEls) {
149150
const linkHref = linkEl.getAttribute("href");
151+
// https://github.com/quarto-dev/quarto-cli/issues/9411
152+
// only add the event listener for internal links
153+
try {
154+
const linkUrl = new URL(linkHref);
155+
if (linkUrl.origin !== currentUrl.origin) {
156+
continue;
157+
}
158+
} catch (_e) {
159+
// if the link is not a valid URL, skip it
160+
continue;
161+
}
150162
linkEl.addEventListener("click", () => {
151163
QuartoDashboardUtils.showPage(linkHref);
152164
return false;

0 commit comments

Comments
 (0)