Repository navigation
fix(viewer): a click on Save leaves the focus in the document, so Ctrl/⌘+Z undoes there - #65
Open
pierreneter wants to merge 1 commit into
Open
pierreneter wants to merge 1 commit into
pierreneter wants to merge 1 commit into
Conversation
…l/⌘+Z undoes there The Save button took the focus on a click and was disabled while it saved. A disabled button loses its focus to the page, out of the viewer, so Ctrl/⌘+Z and every other shortcut did nothing until the document was clicked again. The Undo button still worked. The button now keeps the focus where it was on mousedown, as the toolbar's buttons do, and is aria-disabled while it saves, so a keyboard focus on it stays too. saveFile already refuses a second save while one runs. The e2e tests that clicked back into the document after Save no longer do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What
After a click on Save, Ctrl/⌘+Z did nothing in Word, Excel and PowerPoint documents until the document was clicked again. The Undo button still worked, so the history was intact. Only the keyboard was lost.
Why
The Save button took the focus on a click and had
disabled={saving}. A disabled button loses its focus, and here the focus went to<body>, outside the viewer. No handler gets keys from there, so every shortcut did nothing, not only undo.Saving with Ctrl/⌘+S was not affected, because the focus never left the document.
Fix
In
src/react/DocViewer.tsx, the Save button:mousedown, as the toolbar's buttons do. A click leaves the focus, the caret and the selection where they were.aria-disabledinstead ofdisabledwhile it saves. A keyboard user who tabs to Save and presses Enter keeps the focus on the button.saveFilealready refuses a second save while one runs.styles.cssgives.de-mode[aria-disabled='true']the same faded look as:disabled.Tests
e2e/focus-qa3.spec.ts: Save, then Ctrl/⌘+Z undoes in a document, a sheet and slides, and the Save button keeps a keyboard focus while it saves. All 4 fail without the fix and pass with it.large-deck.pptxsample is not on this machine.Control+cto copy, which does not copy on macOS. A copy of it withControlOrMeta+passes.🤖 Generated with Claude Code