Repository navigation
Fix notebook preview back link having no href in websites - #15018
Merged
Merged
Conversation
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
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In website projects the "Back to Article" control of a notebook preview is an
<a>withouthref. 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 withhref="".Root cause
The
href=""in standalone renders comes from thefixEmptyHrefsHTML postprocessor (src/core/html.ts). It is registered insrc/command/render/pandoc.tsonly when the project is not a website. It was added for the tabset cursor in #1227, with a comment sayingquarto-nav.jsdoes the same in websites. That is not true:quarto-nav.jsnever sets empty hrefs, so website renders never got one.Using
backHrefalone would not cover the reported case. It is only set whennotebook-preview-options.backis true, which only manuscripts set by default.Fix
The embed template now emits
hreffrombackHrefwhen it is set, and an emptyhrefotherwise. Theonclickhandler stays, so the click behavior is unchanged.Alternatives considered:
/was deemed wrong, as it breaksfile://and sub-path deployments.fixEmptyHrefsfor websites was deemed too broad. It is a site-wide change and would make the sidebar-collapse anchors innav-before-body.ejsfocusable 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):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.