Skip to content

Commit

Permalink
Merge pull request #11264 from quarto-dev/bugfix/9411
Browse files Browse the repository at this point in the history
dashboard - don't interfere with external links
  • Loading branch information
cscheid authored Oct 31, 2024
2 parents efe1328 + 0b8db59 commit 1947398
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ All changes included in 1.6:

## `dashboard` Format

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

## `html` Format
Expand Down
12 changes: 12 additions & 0 deletions src/resources/formats/dashboard/quarto-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,20 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
const linkEls = document.querySelectorAll(
".quarto-dashboard-content a:not(.nav-link)"
);
const currentUrl = new URL(window.location.href);
for (const linkEl of linkEls) {
const linkHref = linkEl.getAttribute("href");
// https://github.com/quarto-dev/quarto-cli/issues/9411
// only add the event listener for internal links
try {
const linkUrl = new URL(linkHref);
if (linkUrl.origin !== currentUrl.origin) {
continue;
}
} catch (_e) {
// if the link is not a valid URL, skip it
continue;
}
linkEl.addEventListener("click", () => {
QuartoDashboardUtils.showPage(linkHref);
return false;
Expand Down

0 comments on commit 1947398

Please sign in to comment.