Skip to content

fix(sheet): save active cell before leaving sheet#1108

Open
benpeter wants to merge 5 commits into
mainfrom
sheetfix
Open

fix(sheet): save active cell before leaving sheet#1108
benpeter wants to merge 5 commits into
mainfrom
sheetfix

Conversation

@benpeter

Copy link
Copy Markdown

Summary

Commit the active spreadsheet cell and flush the pending autosave before navigating to the parent folder. Queued saves retain the sheet path where the edit occurred.

Fixes #1097.

Live test

Edited the final cell, immediately navigated to the parent folder without tabbing out or waiting for the debounce, then reopened the sheet. The edited value was retained.

@aem-code-sync

aem-code-sync Bot commented Jul 14, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

@hannessolo

Copy link
Copy Markdown
Contributor

Thanks a lot for your PR.

I see the issues this is trying to fix but I'm not yet convinced this is the right fix:

  • When the user navigates away using any other method (close the tab, close the browser, use the browser back button, ...) this won't catch it
  • I personally consider the behaviour that a cell you didn't focus out of isn't saved intentional - if you hit esc while editing the cell, the edit is undone, so in my mind it isn't finalised until you hit enter or focus out. This is consistent with how google sheets behaves, although that warns you if you try to close the tab with unsaved changes

That said I'm open to be convinced otherwise - @mhaack @shsteimer what do you think?

@hannessolo

Copy link
Copy Markdown
Contributor

Something we were discussing to add regardless is an indicator to show whether the page has been saved.

@benpeter

Copy link
Copy Markdown
Author

thanks @hannessolo - I can relate, expectations might vary a lot and probably indicator + a warning are the right middle ground.

also, nothing new as noted on #1097, but maybe @mhaack saw something that I didn't

@benpeter

Copy link
Copy Markdown
Author

webkit tests fail, so I'll push a fix for that either way so this PR is in consistent state

benpeter added 5 commits July 15, 2026 11:06
commitActiveEditors' test modelled edition as the cell element, but
jspreadsheet sets it to [cell, innerHTML, colIndex, rowIndex] while a cell
editor is open. closeEditor expects the cell (edition[0]). The wrong model
let the code pass the whole array to closeEditor without the test noticing,
which is the webkit save-before-navigation failure.
…er nav

commitActiveEditors passed the whole edition array to closeEditor, which
expects the cell element (edition[0]) and calls edition.getAttribute. Passing
the array threw, so beforeNavigate never reached flushPendingSave and the last
edit was lost.

It only surfaced on webkit: chromium and firefox blur-close the open cell
editor before the click handler runs, so commitActiveEditors sees no active
edition and the blur-triggered save flushes. Webkit leaves the editor open, so
the bad call ran and threw. Passing edition[0] commits the open editor, which
fires onafterchanges and lets the pending save flush.
The parent-folder link commits the open editor and flushes the save, then
navigates to the parent folder. The test reloaded the sheet immediately after
the click, racing that async save+navigation: webkit lost the save, and once
the save was awaited, firefox landed on the parent folder instead of the sheet.
Waiting for the app to leave the sheet view guarantees the save landed
(beforeNavigate awaits it) before reopening the sheet to assert.

Verified locally against the sheetfix preview on chromium, firefox and webkit,
for both the da-sites/da-status and da-testautomation/da-e2e-tests org/site
configs (the two CI suites).
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.

[hlx6] sheets are not saved correct

2 participants