Skip to content

Commit 126b240

Browse files
committed
fix(web): sidebar skips recording drag releases while hidden
1 parent 66de0e6 commit 126b240

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ it("does not slide rows from positions measured before a window resize", () => {
6060
expect(fixture.list.getAnimations({ subtree: true })).toHaveLength(0);
6161
});
6262

63-
it("does not queue drag-release motion while the document is hidden", () => {
63+
it("does not replay a drag release that ended while the document was hidden", () => {
6464
using fixture = mountList(["a", "b"]);
65-
using _visibility = vi.spyOn(document, "visibilityState", "get").mockReturnValue("hidden");
65+
using visibility = vi.spyOn(document, "visibilityState", "get").mockReturnValue("hidden");
6666
fixture.motion.release();
67+
visibility.mockReturnValue("visible");
6768
fixture.list.prepend(fixture.rows.get("b")!);
68-
fixture.motion.update(true);
69+
fixture.motion.update(false);
6970
expect(fixture.list.getAnimations({ subtree: true })).toHaveLength(0);
7071
});

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

Lines changed: 2 additions & 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 (document.visibilityState === "visible" && !reducedMotion?.matches) {
231+
if (!reducedMotion?.matches) {
232232
for (const [node, position] of next) {
233233
const top = released.get(node);
234234
if (top !== undefined) move(node, top - position.top);
@@ -240,6 +240,7 @@ export function createSidebarListMotion(parent: HTMLUListElement) {
240240
},
241241
release() {
242242
suspend();
243+
if (document.visibilityState !== "visible") return;
243244
const origin = parent.getBoundingClientRect().top;
244245
released = new Map(
245246
Array.from(parent.children)

0 commit comments

Comments
 (0)