Skip to content

Commit 2f28072

Browse files
fix(mobile): keep route rows in place when a drag drops
On drop, the rows that had shifted aside kept their offsets for a frame after taking their new slots, so they slid out of the card and it looked empty for a moment. Each drop now remounts the rows, so the new order and the cleared offsets land together. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 00838b8 commit 2f28072

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎apps/mobile/src/features/settings/EnvironmentRoutesSection.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ export function EnvironmentRoutesSection({
7474
);
7575
// Rows size to their content, so a drag measures how far it has moved past each one.
7676
const [heights, setHeights] = useState<ReadonlyMap<string, number>>(() => new Map());
77+
// Each drop remounts the rows so the new order and the cleared drag offsets
78+
// land in one frame. Kept rows would show their old offsets in their new
79+
// slots until the animated style catches up, and the card flashes empty.
80+
const [drops, setDrops] = useState(0);
7781
if (entry === undefined) return null;
7882

7983
const byId = new Map(saved.map((route) => [connectionRouteId(route.target), route]));
@@ -156,7 +160,7 @@ export function EnvironmentRoutesSection({
156160
: 0;
157161
return (
158162
<RouteRow
159-
key={id}
163+
key={`${id}:${drops}`}
160164
route={route}
161165
position={index + 1}
162166
count={routes.length}
@@ -173,6 +177,7 @@ export function EnvironmentRoutesSection({
173177
onDragMove={(translation) => setDrag({ id, translation })}
174178
onDragEnd={(translation, cancelled) => {
175179
setDrag(null);
180+
setDrops((count) => count + 1);
176181
if (!cancelled) move(index, dropIndex(index, translation));
177182
}}
178183
onStep={(direction) => move(index, direction === "up" ? index - 1 : index + 1)}

0 commit comments

Comments
 (0)