Repository navigation
Keep the keyboard focus where it was when a revealjs presentation is shown again - #15090
Open
jooyoungseo wants to merge 2 commits into
Open
jooyoungseo wants to merge 2 commits into
jooyoungseo wants to merge 2 commits into
Conversation
…shown again The bundled reveal.js moves the focus to the body each time the page becomes visible, if anything else had it (onPageVisibilityChange). Switching tabs and back therefore took a reader off the link or chart they were on, and NVDA and JAWS, which pass the arrow keys on only while the focus is in the deck, went back to browse mode. reveal.js does this so that its shortcuts work after the reader clicked into something, but keys pressed on a link or a button reach it anyway. Only keys pressed inside a frame do not, so the new revealjs-0003 patch moves the focus only out of a frame, and onto the deck rather than the body. The bundles are rebuilt from 5.1.0 with the three patches; with patches 0001 and 0002 alone the same build reproduces the current bundles byte for byte. Fixes quarto-dev#15079
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. |
The test of a frame handing the focus to the deck failed in Firefox on CI. Playwright's Firefox emulates a focused page by skipping the blur when the focus leaves a document, so focusing the deck straight from a frame left the focus in the frame. Blurring the frame first, as reveal.js did before moving the focus to the body, takes the focus out of the frame, and focusing the deck then works. Firefox 158 moves the focus either way.
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.
Description
Fixes #15079.
Each time the page becomes visible again, for example after switching tabs, the bundled reveal.js moved the focus to
<body>if anything else had it (onPageVisibilityChange()). A reader lost their place on a link or in a chart. NVDA and JAWS, which pass the arrow keys on only while the focus is in the deck, went back to browse mode.reveal.js does this "to ensure we can use keyboard shortcuts". But keys pressed on a link or a button reach it anyway: it ignores keys only in inputs, text areas and editable content. The keys it cannot get are the ones pressed inside a frame. So the new source patch
revealjs-0003-focus-on-return.patchmoves the focus only out of a frame, and onto the deck (withtabindex="-1") rather than the body. It blurs the frame first, as reveal.js did: Playwright's Firefox, which CI runs, otherwise leaves the focus in the frame. Anywhere else, the focus stays where the reader left it.The patch follows #15020 and #15034.
update-html-dependencies.tsapplies it after 0001 and 0002, and the bundles and maps are rebuilt from 5.1.0 withnpm ci --ignore-scriptsandgulp js, as that step does. Before adding the patch, the same build with 0001 and 0002 alone reproduced all four committed files byte for byte. That needed the sources the committed maps embed with CRLF line endings to have CRLF line endings in the build too. With 0003, onlyjs/reveal.js's source and the mappings change in the maps.Every reveal.js release from 3.9.2 to 6.0.2 does this, so I'm reporting it to reveal.js as well.
Validation
revealjs-visibility-focus.spec.ts, with a new fixture, checks what happens after the page is hidden and shown again:Playwright does not hide the page when another tab comes to the front, so the test marks the page hidden and then visible and dispatches
visibilitychange. The first three fail without the patch.All revealjs Playwright specs pass in Chromium, except
revealjs-multiplex.spec.ts, which needs the multiplex server that the CI wrapper starts.revealjs-visibility-focus.spec.tsalso passes in Firefox 158 over WebDriver BiDi. WebKit and Playwright's own Firefox were not run locally.The three patches apply in order to a pristine 5.1.0 tree with
git apply --ignore-space-change.Checklist
I have (if applicable):
AI-assisted PR
Generated by Claude Code