mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #883] [MERGED] feat(game): drag-and-swap inventory items in Game Mode #4818
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4818
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/883
Author: @Romuromylus
Created: 5/15/2026
Status: ✅ Merged
Merged: 5/15/2026
Merged by: @Romuromylus
Base:
staging← Head:feat/inventory-drag-swap📝 Commits (3)
ad64535feat(game): drag-and-swap inventory items in Game Mode3449319refactor(game-inventory): migrate drag-swap from HTML5 DnD to @dnd-kit/core6ee5ce6fix(game-inventory): guard reorder rollback against stale revert📊 Changes
4 files changed (+198 additions, -39 deletions)
View changed files
📝
packages/client/package.json(+1 -0)📝
packages/client/src/components/game/GameInventory.tsx(+127 -39)📝
packages/client/src/components/game/GameSurface.tsx(+33 -0)📝
pnpm-lock.yaml(+37 -0)📄 Description
Linked issue
Closes #861
Why this change
Game Mode players currently have no way to manually organize their inventory — add/rename/use/remove exist, but the slot order is whatever order items were acquired in. The issue (filed from Discord by drakonbane, triaged
normal-scopeby @cha1latte) asks for drag-and-swap so the grid can be tidied.Per the triage note I scoped this slice to "drag/swap within the current inventory grid first"; cross-page reorder is deliberately deferred.
What changed
packages/client/src/components/game/GameInventory.tsx— filled slots are draggable via@dnd-kit/core. Dragging item A onto item B (within the current page) triggers a swap; empty slots are non-droppable. While dragging, the source slot dims and the hovered target gets an amber ring for visual feedback. Refactored the slot rendering into anInventorySlotsubcomponent becauseuseDraggable/useDroppableare hooks. New optionalonReorderItem(fromIndex, toIndex)prop; behavior is unchanged when the prop is omitted.packages/client/src/components/game/GameSurface.tsx— newhandleReorderInventoryItemwired to the prop. Swaps two entries ingameInventory, applies the change optimistically, and persists via the existingupdateChatMetadatamutation. On error, rolls back the local state and surfaces a toast.packages/client/package.json— adds@dnd-kit/core@6.3.1(MIT, ~12KB gzipped, zero GH advisories, ~16M weekly downloads, transitive footprint is onlytslibvia@dnd-kit/utilities+@dnd-kit/accessibility).History note: the first commit used native HTML5 drag-and-drop with no new dependency. After review feedback flagged that HTML5 DnD events don't fire on iOS Safari, the second commit migrated to
@dnd-kit/coreto get real touch support. TheMouseSensoris configured with a 4px distance threshold so quick clicks still select, and theTouchSensoruses a 200ms hold + 5px tolerance so swipe-to-scroll still works on mobile.Design choices worth flagging:
gameInventoryis array-ordered andnormalizeGameInventoryItemspreserves order, so the existingPATCH /chats/:id/metadataroute round-trips a reorder unchanged.playerStats.inventoryleft untouched. That array is the agent-facing detailed inventory (withdescription,location). The agent indexes by name; its array order is not observable. Skipping the mirror avoids a second PATCH and a second rollback path.aria-grabbedreplaced witharia-pressed.aria-grabbedwas deprecated in ARIA 1.1; current screen readers ignore it.touch-action: noneonly on draggable slots. Required forTouchSensoractivation to win over browser scroll gestures. The modal background, pagination row, and action bar remain pannable.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Desktop / mouse:
Mobile / touch:
@dnd-kit/core.Docs and release impact
UI evidence (if applicable)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.