From 55211c0e699817ff0deb323a4b22011002896714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 22 Oct 2026 10:20:30 +0200 Subject: [PATCH] fix(pwa): never arm pull-to-refresh while a sheet holds the page The listeners sit on window, so a drag inside an open sheet on the dashboard or the insights page armed the refresh behind it. They stand down while the scroll lock marks the body. --- src/hooks/use-pull-to-refresh.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hooks/use-pull-to-refresh.ts b/src/hooks/use-pull-to-refresh.ts index bf736a729..10471fa4b 100644 --- a/src/hooks/use-pull-to-refresh.ts +++ b/src/hooks/use-pull-to-refresh.ts @@ -84,15 +84,21 @@ export function usePullToRefresh({ setPullDistance(0); }; + // A sheet or dialog is open: Radix's scroll lock marks the body while it + // holds the page. A drag inside the sheet (down to close it, or along + // its content) is the sheet's, never a pull on the page behind it; the + // listeners sit on `window`, so without this they saw every one. + const modalOpen = () => document.body.hasAttribute("data-scroll-locked"); + const onTouchStart = (e: TouchEvent) => { - if (busy || e.touches.length !== 1 || !atTop()) return; + if (busy || e.touches.length !== 1 || !atTop() || modalOpen()) return; startY = e.touches[0].clientY; }; const onTouchMove = (e: TouchEvent) => { if (busy || startY === null) return; const dy = e.touches[0].clientY - startY; - if (dy <= 0 || !atTop()) { + if (dy <= 0 || !atTop() || modalOpen()) { // Upward drag or the page started scrolling — stand down quietly. if (pulling) reset(); return;