Skip to content

fix(grid): keep cursor stable during cell dragging (#936) - #1095

Merged
aiongg merged 1 commit into
storytold:mainfrom
Zaxaerith:fix/grid-drag-cursor-936
Oct 22, 2026
Merged

aiongg merged 1 commit into
storytold:mainfrom
Zaxaerith:fix/grid-drag-cursor-936

Conversation

@Zaxaerith

Copy link
Copy Markdown
Contributor

Problem

Dragging a cell selection could switch the requested cursor between Cell, Move and Crosshair as the pointer crossed the changing selection border and fill handle. Other grid drags could also lose their cursor over unrelated hover targets.

Root cause

The hover cursor block ran before the grid processed drag state changes, and continued hit-testing during active drags. It could overwrite the cursor for the actual operation and miss the first drag frame.

Changes

  • Decide the grid cursor after interaction updates the drag state, including drag start and release.
  • Give a recognized, held drag its own cursor: Cell for selection, Crosshair for fill, Move for cell/column/object moves, the existing axis cursors for resizing and freezing, and the existing corner cursor for object resizing. Whole-line selection keeps the default header cursor.
  • Retain normal hover hit-testing when no drag is active, including presses below egui's threshold and transient state left by a click. Pen and Eraser keep their Crosshair over cells.
  • Preserve hover-cell bookkeeping for cell notes independently of cursor ownership, including with Draw tools active.
  • Update the affected UI parity entry without changing interaction timing or adding persistent state.

Regression tests

crates/ui-egui/tests/drag_cursor.rs drives the real SheetApp through egui pointer press, movement and release events, asserting platform_output.cursor_icon on movement and following idle frames. It also checks selection, filled values, moved values/columns, resized dimensions, freeze counts and ink creation.

Coverage includes selection borders and fill handles, frozen panes, leaving the grid, RTL coordinates, fill, moves, both resize/freeze axes, column reordering, whole-line selection, object move/resize, Draw cursors and hover tracking, and a rapid press following a click.

Eight behavioral assertions failed against unchanged upstream grid code (including Select requesting Move and Fill requesting Cell). All ten final cursor tests pass with this change.

Validation

  • cargo test --offline -p gridcraft-ui-egui --test drag_cursor: 10 passed.
  • Fourteen related UI integration suites: 79 passed, including the new tests.
  • cargo fmt --all -- --check and git diff --check: passed.
  • Offscreen snapshot example: rendered and inspected a 1200 x 800 PNG with synthetic sales data. This checks layout; it does not measure native cursor flicker.
  • Full cargo xtask ci: all eight gates passed (fmt, Clippy with warnings denied, workspace tests, assets, layers, WASM, Parity and Keytips). Workspace tests: 1607 passed, zero failed, one timing benchmark ignored by default. Run on Windows with Rust 1.99.0, CARGO_BUILD_JOBS=1 and RUST_TEST_THREADS=2.

An initial parallel compilation exhausted Windows commit memory/page-file capacity. Retrying with one Cargo build job succeeded for the targeted UI suites. No global configuration was changed.

The first completed CI run reached Parity after passing fmt, Clippy, workspace tests, assets, layers and WASM, but the generated-file checks compared the Windows CRLF checkout with LF output. Converting only the three generated working copies to LF made Parity and Keytips pass; each normalized file's Git blob hash equals upstream/main, and no generated-file change is included in the commit. The WASM check retains an existing dead-code warning for Modified::At and Modified::Unknown in unchanged backstage.rs.

Scope / limitations

This fixes cursor priority for the existing drag modes. It does not add header arrow cursors, a custom white cell cursor, assets, settings, animation changes or select-on-press behavior. No unmerged code from #909 or #927 is included; those interaction changes may require a rebase if merged first. The work is independent of #969.

Windows native cursor sampling, other operating systems, touch input and every object kind were not exercised. The cursor evidence is egui output from simulated pointer events on Windows; a PNG cannot establish native cursor stability.

Prepared with Codex assistance. The commit uses the Codex co-author identity already accepted in GridCraft.

Related Issue

Fixes #936

@aiongg
aiongg merged commit ad7fe4e into storytold:main Oct 22, 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.

fix(grid): cursor flickers between arrow and Move while drag-selecting (hover cursor runs during drags)

2 participants