mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
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.
This commit is contained in:
1 parent
1cc1cda7aa
commit
55211c0e69
1 file changed
+8
-2
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user