Skip to content

Fix notebook preview back link having no href in websites - #15018

Merged
cderv merged 2 commits into
mainfrom
fix/issue-15015
Oct 9, 2026
Merged

cderv merged 2 commits into
mainfrom
fix/issue-15015

Conversation

@cderv

@cderv cderv commented Oct 9, 2026

Copy link
Copy Markdown
Member

In website projects the "Back to Article" control of a notebook preview is an <a> without href. It has no link role and is not in the tab order, so keyboard users cannot go back to the article. Standalone renders are not affected, because they end up with href="".

Root cause

The href="" in standalone renders comes from the fixEmptyHrefs HTML postprocessor (src/core/html.ts). It is registered in src/command/render/pandoc.ts only when the project is not a website. It was added for the tabset cursor in #1227, with a comment saying quarto-nav.js does the same in websites. That is not true: quarto-nav.js never sets empty hrefs, so website renders never got one.

Using backHref alone would not cover the reported case. It is only set when notebook-preview-options.back is true, which only manuscripts set by default.

Fix

The embed template now emits href from backHref when it is set, and an empty href otherwise. The onclick handler stays, so the click behavior is unchanged.

Alternatives considered:

  • Falling back to / was deemed wrong, as it breaks file:// and sub-path deployments.
  • Enabling fixEmptyHrefs for websites was deemed too broad. It is a site-wide change and would make the sidebar-collapse anchors in nav-before-body.ejs focusable duplicates of the toggle button.

The new Playwright spec fails without the template change and passes with it on chromium and firefox. WebKit was not verified locally, as it never Tabs to links on Windows.

Fixes #15015

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: DeepWiki MCP, local clone
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.

cderv added 2 commits October 9, 2026 19:05
The "Back to Article" control in the embed template was an <a> with only
an onclick handler. Standalone renders got href="" from the
fixEmptyHrefs HTML postprocessor, but pandoc.ts skips that postprocessor
for website projects, so on website preview pages the element had no
link role, was not in the Tab order, and keyboard users could not go
back to the article.

The template now writes the href itself: the article URL when backHref
is known (manuscripts), else href="" as standalone renders already had.
The onclick still returns false, so the history-based back behavior is
unchanged.

The Playwright test opens the preview from the article, Tabs to the
link and presses Enter, for a website and a standalone render.

Fixes #15015
@posit-snyk-bot

posit-snyk-bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv
cderv merged commit a57cc76 into main Oct 9, 2026
51 checks passed
@cderv
cderv deleted the fix/issue-15015 branch October 9, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

a11y: notebook preview "Back to Article" link has no href in website projects

2 participants