You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: make sheet version restore fully functional (#957)
* fix: make sheet version restore fully functional
Three bugs made it impossible to restore a sheet from version history:
1. `resetSheets` cleared `el.className` (removing `da-sheet`), so the
second restore's `document.querySelector('.da-sheet')` returned null
and crashed with "Cannot read properties of null (reading 'jexcel')".
Fix: remove only the `jexcel_tabs` class — the one jspreadsheet checks
to decide whether to reuse existing children — instead of wiping all
classes.
2. The restore handler called `staleCheck.markSynced(verReview.data)`
with jspreadsheet-format data. `checkForDrift` fetches DA-JSON from
the server, so these formats never matched, drift was always detected,
and `onStale({ dirty: false })` silently reloaded the sheet from the
server — undoing the restore before the user could save.
Fix: call `staleCheck.markEdited()` instead, preserving the correct
server-content baseline while marking the sheet dirty so any genuine
concurrent edit shows a dialog rather than a silent reload.
3. After restore `da-sheet-panes.data` was never updated, so the Preview
pane still showed the pre-restore content.
Fix: set `sheetPanes.data = convertSheets(daTitle.sheet)` after
reinitialising the spreadsheet.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: persist restored sheet version to server
Sheet version restore was only updating the local jspreadsheet UI; the
restored content was never POSTed, so a page refresh re-fetched the old
data from the server.
Extract restoreVersion into utils.js and have it call saveSheets after
re-initializing the sheet — that drives the PUT to /source plus preview
sync and staleCheck markSynced. Add unit tests covering both the PUT
and the preview-pane update.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Chris Peyer <chrischrischris@users.noreply.github.com>
0 commit comments