Skip to content

fix(sheet): persist row/column delete and move in sheet editor#1074

Open
shsteimer wants to merge 8 commits into
mainfrom
sheetdel
Open

fix(sheet): persist row/column delete and move in sheet editor#1074
shsteimer wants to merge 8 commits into
mainfrom
sheetdel

Conversation

@shsteimer

@shsteimer shsteimer commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What changed

ondeleterow, ondeletecolumn, onmoverow, and onmovecolumn are now wired to trigger a save, the same as onafterchanges already does for cell edits. Row/column inserts are left unhooked - a fresh row/column starts empty, and once real content lands in it, onafterchanges captures it anyway.

Also adds Playwright e2e tests that drive a real jspreadsheet-ce grid end-to-end (delete two rows, delete two columns, reload, verify the deletion persisted), plus a unit test following this repo's existing handleSave testing convention, covering all four new hooks.

Row/column move (onmoverow/onmovecolumn) are covered at the unit level only - e2e coverage would need to simulate real drag-and-drop, which is more fragile than a context-menu click for comparatively low added value given the unit tests + library source already confirm the mutation path is symmetric to delete.

Why

jspreadsheet-ce only fires onafterchanges for cell-value edits. Deleting or reordering rows/columns never marked the sheet dirty or triggered a save, so those changes were silently lost on reload unless followed by an unrelated cell edit or an explicit Save click.

🤖 Generated with Claude Code

jspreadsheet-ce only fires onafterchanges for cell-value edits, not for
row/column deletion or row reordering. Those structural changes never
marked the sheet dirty or triggered a save, so deleting rows (e.g. via
da.live/sheet) was silently lost on reload unless followed by an
unrelated cell edit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@aem-code-sync

aem-code-sync Bot commented Jul 6, 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

Replace the sinon fake-timer unit test (which needed a dynamic-import
pre-warm hack to avoid a race) with a lighter unit test that follows
this repo's existing handleSave convention (real setTimeout wait past
the debounce), and add a Playwright e2e test that drives the real
jspreadsheet-ce grid end-to-end: delete two rows, reload, and verify
the deletion actually persisted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@shsteimer shsteimer requested a review from hannessolo July 6, 2026 22:50
@shsteimer shsteimer marked this pull request as ready for review July 6, 2026 22:50
Comment thread blocks/sheet/utils/index.js
onmovecolumn mutates the underlying data model the same way onmoverow
does (jspreadsheet-ce's moveColumn splices options.data in place), so
it was hitting the same silent-loss-on-reload bug that this branch
already fixes for row/column delete and row move.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@shsteimer shsteimer changed the title fix(sheet): persist row/column delete and row move in sheet editor fix(sheet): persist row/column delete and move in sheet editor Jul 6, 2026
Mirrors the existing row-delete e2e test for ondeletecolumn - deletes
two columns via the header context menu and verifies the deletion
survives a reload. Row/column move are left to unit-test-only
coverage for now; simulating drag-and-drop in Playwright is more
fragile than a context-menu click for comparatively low added value.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@hannessolo hannessolo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not saving on sort is fine

hannessolo
hannessolo previously approved these changes Jul 7, 2026
shsteimer and others added 2 commits July 7, 2026 07:59
CI showed both delete tests timing out on the second right-click:
jSuites' document-level contextmenu listener dispatches based on
document.activeElement, and after the first menu-item click that's
still the (now-closed) link - so a follow-up right-click on a new
target never reopens a fresh menu. Select both rows/columns first
(click + shift-right-click extends the selection) and delete them in
a single context-menu action instead of two separate open/click
cycles.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… test

columnDrag is off so onmovecolumn can never fire; removing the dead
binding and its unit test case. Adds e2e coverage for row-move persistence.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Selecting a range via shift-right-click doesn't extend the jspreadsheet-ce
selection the way a plain shift-click does, so only the last-clicked row/column
was ever actually deleted. Switch to click -> shift-click (extend selection) ->
right-click (open context menu without collapsing it).

Also replace fixed waitForTimeout delays with waiting for the actual debounced
save request to complete, since the delay needed varies with machine/network
speed and a fixed timeout was masking this selection bug.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

2 participants