mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 14:16:12 +00:00
fix(pwa): fix pull-to-refresh's at-top check and extend coverage
The authenticated shell's actual scroll container is <main id="main-content"> (AuthShell sets it overflow-y-auto inside a height-locked layout); document.scrollingElement never moves there, so the gesture's "only arm at the top of the page" check was permanently true regardless of how far a user had scrolled a long list. Point it at the real scroll container instead, with the old document-root check kept as a fallback for the few body-scrolled surfaces outside the shell. Extend pull-to-refresh from 4 pages (labs/checkups/mood/measurements) to the dashboard, /insights, /medications, and the documents vault — the sharpest PWA-resume-staleness surfaces, per the audit: a background-refreshed dose or a cross-device write otherwise sits stale until a full remount or the staleTime window lapses.
This commit is contained in:
1 parent
c1c3aa9754
commit
b00450aec8
5 files changed
+90
-8
No files matched your search
@@ -60,8 +60,22 @@ export function usePullToRefresh({
|
||||
let busy = false;
|
||||
let lastDistance = 0;
|
||||
|
||||
const atTop = () =>
|
||||
(document.scrollingElement?.scrollTop ?? window.scrollY) <= 0;
|
||||
// v1.30.1 M12 — the authenticated shell's actual scroll container is
|
||||
// `<main id="main-content">` (`AuthShell` sets it `overflow-y-auto`
|
||||
// inside a height-locked `h-dvh` layout); `document.scrollingElement`
|
||||
// never moves there; it stays permanently at 0. Checking the document
|
||||
// root meant "at top" was always true regardless of how far the user
|
||||
// had actually scrolled a long list — a downward drag mid-scroll could
|
||||
// arm the pull gesture instead of just scrolling the list. Falls back
|
||||
// to the document root for the few body-scrolled surfaces (public
|
||||
// pages) that render outside the shell's `#main-content`.
|
||||
const atTop = () => {
|
||||
const main = document.getElementById("main-content");
|
||||
const scrollTop = main
|
||||
? main.scrollTop
|
||||
: (document.scrollingElement?.scrollTop ?? window.scrollY);
|
||||
return scrollTop <= 0;
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
startY = null;
|
||||
|
||||
Reference in new issue
Block a user