Skip to content

Commit c22ec5c

Browse files
committed
fix(web): retain unfinished shelf travel for new rows
1 parent 2f69765 commit c22ec5c

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎apps/web/src/components/Sidebar.motion.test.ts‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ describe("sidebar list motion", () => {
283283
expect(a.animations[0]!.cancel).toHaveBeenCalledOnce();
284284
expect(fresh.animate).toHaveBeenLastCalledWith(
285285
[
286-
{ opacity: 0, transform: "translateY(0px)" },
286+
{ opacity: 0, transform: "translateY(83px)" },
287287
{ opacity: 1, transform: "translateY(0px)" },
288288
],
289289
{
@@ -308,7 +308,7 @@ describe("sidebar list motion", () => {
308308
expect(clone.animate).toHaveBeenCalledWith(
309309
[
310310
{ opacity: 1, transform: "translateY(0px)" },
311-
{ opacity: 0, transform: "translateY(0px)" },
311+
{ opacity: 0, transform: "translateY(-83px)" },
312312
],
313313
{
314314
duration: 150,
@@ -355,6 +355,26 @@ describe("sidebar list motion", () => {
355355
);
356356
});
357357

358+
it("rides new rows on a retained header's unfinished travel", () => {
359+
const header = new TestRow("header", 32);
360+
const above = new TestRow("above", 39);
361+
const incoming = new TestRow("incoming", 36);
362+
const { motion, layout } = fixture([header]);
363+
motion.update(true);
364+
layout([above, header]);
365+
motion.update(true);
366+
header.animations[0]!.progress = 0.25;
367+
layout([above, header, incoming]);
368+
motion.update(true);
369+
expect(incoming.animate).toHaveBeenLastCalledWith(
370+
[
371+
{ opacity: 0, transform: "translateY(-30px)" },
372+
{ opacity: 1, transform: "translateY(0px)" },
373+
],
374+
{ duration: 150, easing: "ease-out" },
375+
);
376+
});
377+
358378
it("cancels in-flight row travel when a bulk update skips animation", () => {
359379
const a = new TestRow("a");
360380
const b = new TestRow("b");

‎apps/web/src/components/Sidebar.motion.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export function createSidebarListMotion(parent: HTMLUListElement) {
171171
const node = order[cursor]!;
172172
const delta = movedDelta.get(node);
173173
if (delta !== undefined) return delta;
174-
if (retained(node)) return 0;
174+
if (retained(node)) return remainingOffset(node);
175175
}
176176
return undefined;
177177
};

0 commit comments

Comments
 (0)