Skip to content

fix: preserve saved layout after cancelling a cross-grid drag - #3418

Merged
adumesny merged 1 commit into
gridstack:masterfrom
sameerdeolalikar:fix/cancelled-drag-saved-position
Sep 28, 2026
Merged

adumesny merged 1 commit into
gridstack:masterfrom
sameerdeolalikar:fix/cancelled-drag-saved-position

Conversation

@sameerdeolalikar

Copy link
Copy Markdown
Contributor

Problem

In a four-column grid, drag a two-column widget into another grid, return to the original grid, and press Escape. The widget returns visually, but save(false) can contain the transient drag position (for example, x=3, y=1 instead of x=0, y=0). Saving and reloading then moves the cancelled widget.

Change

Clamp the temporary drag preview to the available columns before calling nodeBoundFix(). Otherwise its out-of-bounds preview coordinates are cached as an intentional wider responsive layout, and that cache later overrides the restored position during save. The normal handling of genuinely wider loaded layouts is unchanged.

This addresses a saved-layout consequence of cross-grid cancellation; it is not a replacement for the existing cancellation restoration code.

Validation

  • Added a native Playwright regression covering cross-grid drag, return, Escape, saved data, and reload. It fails on the base commit with x=3/y=1 and passes with this fix.
  • Core Vitest suite: 414 passed.
  • Core build (including TypeScript) and source ESLint passed.
  • A separate Chromium reproduction checked both boards, unchanged sibling positions, absence of committed drops/placeholders, and save/reload: 11 checks passed, versus 8 passed/3 failed before.
  • Firefox, WebKit, mobile browsers, and the Angular/React/Vue wrapper suites were not run.

AI tools assisted implementation and validation. I reviewed the patch and ran the checks above.

@adumesny adumesny left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you.

@adumesny
adumesny merged commit a0bb88a into gridstack:master Sep 28, 2026
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