feat(web): auto-load list pages on scroll with a reliable "Load more" fallback#241
Merged
Merged
Conversation
The list auto-load sentinel observed against the viewport (root: null), but task/patient lists render inside the app shell's overflow-y-auto container. An intervening scroll container clips the observed target, so the generous 800px rootMargin lookahead was silently ignored and the next page only loaded once the user hit the very bottom instead of as the bottom came into view. Resolve the nearest scrollable ancestor and use it as the observer root so the lookahead works in both card and table views (and on mobile). Also switch the sentinel to a callback ref so the observer re-attaches when the node remounts after hasMore toggles false->true, which previously left it watching a detached node. Cover the pure overflow predicate with a test. https://claude.ai/code/session_01W5tHwmE9ZTnCa7HFzqid2A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The task and patient lists should pull the next page automatically as you scroll toward the bottom (when a next page exists), and otherwise offer a Load more button when not already loading — in both card and table views, including on mobile.
The infinite-scroll machinery already landed on this branch (
useAccumulatedPagination+InfiniteScrollSentinel, with the end-of-results loop guard). This PR makes the auto-load actually behave as intended by fixing where the sentinel observes from.The fix
InfiniteScrollSentinelran itsIntersectionObserveragainst the viewport (root: null). But the lists render inside the app shell's scroll container (Page→div.overflow-y-auto). An intervening scroll container clips the observed target, so the generous800pxrootMarginlookahead was silently ignored — the next page only loaded once the user hit the very bottom, instead of as the bottom came into view.Changes:
root, so the lookahead margin works (loads before you reach the bottom). Falls back to the viewport when there is no nested scroll container. New helperutils/scrollableAncestor.ts.hasMoretogglesfalse → true. Previously the setup effect only depended onrootMarginand could be left observing a detached node (or never attach if the list started empty).utils/scrollableAncestor.test.ts).Behaviour after this change
useAccumulatedPaginationend-of-results gating is unchanged).Validation
npm run lint(tsc + eslint) — cleannpm run test— 21 passing (addedscrollableAncestortest)npm run check-translations— clean (loadMorekey present in all locales)https://claude.ai/code/session_01W5tHwmE9ZTnCa7HFzqid2A
Generated by Claude Code