Skip to content

Commit 66de0e6

Browse files
committed
fix(web): drag release no longer queues sidebar motion while hidden
1 parent 84a9d17 commit 66de0e6

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ it("does not slide rows from positions measured before a window resize", () => {
5959
fixture.motion.update(true);
6060
expect(fixture.list.getAnimations({ subtree: true })).toHaveLength(0);
6161
});
62+
63+
it("does not queue drag-release motion while the document is hidden", () => {
64+
using fixture = mountList(["a", "b"]);
65+
using _visibility = vi.spyOn(document, "visibilityState", "get").mockReturnValue("hidden");
66+
fixture.motion.release();
67+
fixture.list.prepend(fixture.rows.get("b")!);
68+
fixture.motion.update(true);
69+
expect(fixture.list.getAnimations({ subtree: true })).toHaveLength(0);
70+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export function createSidebarListMotion(parent: HTMLUListElement) {
228228
}
229229
}
230230
if (released !== null) {
231-
if (!reducedMotion?.matches) {
231+
if (document.visibilityState === "visible" && !reducedMotion?.matches) {
232232
for (const [node, position] of next) {
233233
const top = released.get(node);
234234
if (top !== undefined) move(node, top - position.top);

0 commit comments

Comments
 (0)