Skip to content

fix(cms): infinite scrolling in UserOverview (and RedirectOverview)#1799

Open
johan-bell wants to merge 1 commit into
mainfrom
1797-cms-infinite-scrolling-not-working-in-useroverview
Open

fix(cms): infinite scrolling in UserOverview (and RedirectOverview)#1799
johan-bell wants to merge 1 commit into
mainfrom
1797-cms-infinite-scrolling-not-working-in-useroverview

Conversation

@johan-bell

Copy link
Copy Markdown
Collaborator

Fixes #1797

The bug

useInfiniteScrollList grew its visible window by watching BasePage's scroll container, obtained with inject(basePageScrollKey).

But an overview page renders BasePage — it is BasePage's parent, not its descendant. provide/inject only flows downward, so the inject always resolved to its ref(null) fallback:

const scrollEl = inject(basePageScrollKey, ref(null)); // always null in a page's setup
useInfiniteScroll(() => scrollEl.value, ...);          // → no listener ever attached

The browse list therefore stayed frozen at the first 20 rows, forever.

Search paging was never affected: it uses an IntersectionObserver on a sentinel element, which needs no ancestor lookup. That is exactly why the bug reads as "scrolling works when I search, but not otherwise".

The fix

Apply the sentinel mechanism to the browse window too. useInfiniteScrollList now owns a sentinel ref, which the page binds to a zero-height div rendered after the list:

<div v-if="!searchActive" ref="browseSentinel" class="h-px w-full"></div>

No ancestor lookup, so it works from either side of the slot boundary.

Scope

RedirectOverview calls the same composable the same way and had the identical latent bug — nobody had noticed because the redirect list is short. Fixing the composable fixes both, so both call sites are updated here.

usePinnedToolbarBelowTopbar also injects basePageScrollKey, but it is used from RichTextEditor, which sits inside BasePage's slot. It is correct and untouched.

Why the tests didn't catch it

The old spec mocked useInfiniteScroll away entirely and supplied basePageScrollKey through global.provide — something production never does. It asserted the window logic while stubbing out the very wiring that was broken.

The rewritten spec mounts bare, with no provider in the tree, and drives the real observer.

Verification

  • Full CMS suite: 115 files, 934 tests pass (up from 932).
  • Both new page-level tests and the four new composable tests were confirmed to fail against the pre-fix code (expected 20 to be 25) and pass after — they are real regression guards, not tautologies.
  • npm run type-check, eslint, prettier — clean.

Not verified in a browser. No Docker daemon or api/.env available on the machine this was written on, so there is no CouchDB/API to serve the User docs UserOverview reads (User is a non-synced, API-only type). Paging is covered by the page-level test against a mocked /query, but the real scroll-into-view geometry has not been exercised against a running CMS. Worth a manual check with >20 users before merge.

…jected scroll container

`useInfiniteScrollList` grew its window from `useInfiniteScroll` on BasePage's
scroll container, obtained via `inject(basePageScrollKey)`. But an overview page
*renders* BasePage — it is BasePage's parent, not its descendant — so the inject
always resolved to its `ref(null)` fallback and no scroll listener was ever
attached. The browse list stayed frozen at the first 20 rows.

Search paging was unaffected because it uses an IntersectionObserver on a
sentinel element, which needs no ancestor lookup. Apply the same mechanism to the
browse window: the composable now owns a sentinel ref that the page binds to a
zero-height div after the list.

RedirectOverview had the identical latent bug and is fixed by the same change.

The old spec hid the defect by mocking `useInfiniteScroll` away and supplying
`basePageScrollKey` through `global.provide`, which production never does. The
rewritten spec mounts bare, with no provider in the tree.

Fixes #1797
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants