Repository navigation
fix(viewer): a click on Save leaves the focus in the document, so Ctrl/⌘+Z undoes there - #65
Merged
Merged
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>
Since the Save button keeps the focus in the document, a click on it no longer blurs the cell being typed in, and the blur was what wrote it: the file was saved without the text. The sheet's flush now writes that cell, as Enter would, and waits for the edits sent, before a save or an export from the File menu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ds, then gives the focus back Since a click on Save keeps the focus where it is, a field that writes as it loses the focus was not written before the save: a sheet's name being typed, a font size typed in the toolbar, the word an IME is still composing. The button now blurs that field first, as when it took the focus, then gives the focus back to it, unless its blur put it elsewhere or it went away with its edit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.A click on Save used to blur a cell still being typed in, and that blur wrote the cell. Now the focus stays, so
src/react/xlsx/XlsxView.tsxgives the sheet aflush: before a save, or an export from the File menu, it writes the cell being typed in (in the cell or the formula bar), as Enter would, and waits for the edits sent. Without it the file was saved without the text.Other fields write as they lose the focus too: a sheet's name being typed, a font size typed in the toolbar, the word an IME is still composing (Telex half way through a word). So the click on Save now blurs the field that has the focus, as when the button took it, and then gives the focus back to it, unless its blur put it elsewhere (a cell gives it to its grid) or the field went away with its edit (a sheet's name). Without it, each of these was saved without what was typed.
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.e2e/focus-qa3.spec.ts: text typed in a cell, then in the formula bar, with no Enter before Save, is in the saved file, and Ctrl/⌘+Z then takes the cell back. It fails without the sheet'sflush(the cell is saved empty).Input.imeSetComposition) is in the saved document and the typing goes on after it; a font size typed with no Enter is in the saved document; a sheet's name still being typed is the one saved. All 3 fail without the blur.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