Grid: lock document cursor during resize gesture#77813
Grid: lock document cursor during resize gesture#77813
Conversation
Set `documentElement.style.cursor` while `useDraggable.isDragging` is true so the resize cue persists even when the pointer leaves the handle's hit area. Resolve the document via `ownerDocument` so the lock works inside the block-editor iframe.
The inline `cursor: grab` on each tile beat the document-level resize cursor lock — keeping the hand pointer visible mid-resize. Drop the inline cursor while `interacting` so the gesture's document cursor propagates without an inline override on a descendant.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 7.82 MB ℹ️ View Unchanged
|
|
Flaky tests detected in 71720bd. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25129218077
|
What?
Locks the document cursor to the resize indicator (
nwse-resize/ew-resize) while the user is actively dragging a tile's resize handle. Also clears the tile's inlinecursor: grabwhile any gesture is active so the lock isn't overridden by a more specific inline cursor on a descendant.Part of #77616
Why?
While resizing a tile, the OS cursor reverted to the default arrow as soon as the pointer left the handle's hit area, and to the
grabhand once the pointer entered the body of the tile. The resize cue was lost mid-gesture even though the resize was still in progress, which made the interaction feel disconnected.How?
packages/grid/src/resize-handle.tsxadds auseEffectthat runs whileuseDraggable.isDraggingis true. It writes the appropriate cursor ontodocumentElement.style.cursorand restores the previous value on cleanup. The document is resolved vianodeRef.current?.ownerDocument ?? documentso the lock works inside the block-editor iframe. A localuseRefis merged withsetNodeRef(useMergeRefs) so we have access to the rendered node without taking ownership of it from dnd-kit.packages/grid/src/grid-item.tsxdrops the inlinecursor: grabon the tile root whileinteractingis true. Inline styles on a descendant beat the document-level lock, so without this, the lock had no visible effect once the pointer left the handle. A smallgetItemCursor( disabled, interacting )helper picks'default'(out of edit mode),undefined(gesture in progress), or'grab'(rest in edit mode).Commits
Grid: lock document cursor during resize gesture— the cursor lock itself.Grid: clear tile cursor while a gesture is active— drop the inline tile cursor so the lock can dominate.Testing
Grid/DashboardGrid > Edit Modestory.nwse-resizeover the entire page, including over other tiles and outside the grid.grabover a tile, default elsewhere).rowHeightto a numeric value vs'auto', verify the cursor switches betweennwse-resizeandew-resizeaccordingly.npx tsc --build packages/grid/tsconfig.jsonandnpx jest packages/grid— both should pass.Before:
Screen.Recording.2026-04-29.at.4.09.10.PM.mov
After:
Screen.Recording.2026-04-29.at.4.08.46.PM.mov