From 7c135cd282599e6fb5be98039c2a75f92493316c Mon Sep 17 00:00:00 2001 From: Z8MB1E Date: Tue, 13 Oct 2026 16:42:50 -0400 Subject: [PATCH] fix(grids): resize drag preview when rotating mid-drag dnd-kit pins the DragOverlay container to the activator rect measured at drag start, so pressing R while dragging left the preview at the pre-rotation footprint (a square-ish box for elongated items). Pass the live rotated dimensions through the DragOverlay style prop, which is spread after the pinned rect, in all three R-to-rotate grids: garage vehicle bay, locker, and structure storage. --- src/components/frontend/garage/GarageGrid.tsx | 21 +++++++++++++++++-- src/components/frontend/locker/LockerGrid.tsx | 18 ++++++++++++++-- .../frontend/storage/InventoryGrid.tsx | 15 ++++++++++++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/components/frontend/garage/GarageGrid.tsx b/src/components/frontend/garage/GarageGrid.tsx index 10288ca0..157b4baf 100644 --- a/src/components/frontend/garage/GarageGrid.tsx +++ b/src/components/frontend/garage/GarageGrid.tsx @@ -346,6 +346,16 @@ export function GarageGrid({ } }; + // Drag preview must track mid-drag rotation: dnd-kit pins the overlay + // container to the activator rect captured at drag start, so we override + // its width/height via the style prop (spread after the pinned rect). + const overlayFp = activeItem + ? { + width: pendingRotated ? activeItem.height : activeItem.width, + height: pendingRotated ? activeItem.width : activeItem.height, + } + : null; + return ( drag to move · R to rotate} - + {activeItem ? ( -
+
) : null} diff --git a/src/components/frontend/locker/LockerGrid.tsx b/src/components/frontend/locker/LockerGrid.tsx index cbc87b67..1e8b1c3b 100644 --- a/src/components/frontend/locker/LockerGrid.tsx +++ b/src/components/frontend/locker/LockerGrid.tsx @@ -544,6 +544,13 @@ export function LockerGrid({ onSelectItem(null); }, [onSelectItem]); + // Drag preview must track mid-drag rotation: dnd-kit pins the overlay + // container to the activator rect captured at drag start, so we override + // its width/height via the style prop (spread after the pinned rect). + const overlayFp = activeItem + ? getLockerItemFootprint(activeItem.asset, pendingRotated) + : null; + return ( {/* Tactical drag overlay */} - + {activeItem && ( -
+
- + { + // dnd-kit pins the overlay container to the activator rect + // from drag start; override width/height so mid-drag rotation + // resizes the preview (style is spread after the pinned rect). + const fp = getItemFootprint(activeItem.resource as Resource, pendingRotated); + return { width: fp.width * cellSize - 2, height: fp.height * cellSize - 2 }; + })() + : undefined + } + > {activeItem && ( )}