Repository navigation
feat(search): lift the 50-result cap with paged, distance-segmented results - #88
Merged
Merged
Conversation
`getEvents` capped the distance-ranked search results at the nearest 50, so match #51 was unreachable and nothing said the list was truncated. The cap was a render budget, not a network one — the whole feed is fetched once and cached — so the fix is to move the slice out of the fetcher and into the view. Order of operations is now filter → sort → segment → slice: the client sorts the FULL matching set (so `?sort=soonest` means soonest of the matches, not soonest among an arbitrary nearest-50) and `revealRows` slices it to the revealed page count. The count lives in the URL (`?shown=`), so it survives the drawer stack's remount-on-navigation and a deep link restores it; it stays out of the events query key, so a press never refetches. The "< 500 km" cut becomes a segment boundary rather than a filter. Its pill is gone — it read as a filter the user had chosen, and against an uncapped pool it would have lit on essentially every search. Paging clamps at the boundary, and crossing it takes an explicit press whose label says so ("show events farther than 500 km"), which is what signposts that nearby events have run out. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Unit coverage for the pure parts: the `?shown=`/`?all=1` codec (including the reset the filter/sort setters need, since they copy the params wholesale) and `revealRows` — the boundary clamp, the crossing, the all-far result set, and the no-search-centre case where no boundary forms. Plus a renderToStaticMarkup assertion that the control appears, changes label at the boundary, and drops away while its live region survives it. A Ladle "Paged" case (60 matches) and "Nearby exhausted" case (6 nearby, 40 far) seed the two states from a shared `mockEventSeries` factory. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
SeedSearchParams re-ran its effect whenever react-router rebuilt `setSearchParams` — which it does on every location change — so any write a story made was immediately overwritten by the seed. The paging story looked right and was dead to its own button. Track the seeded value in a ref so each `params` object seeds once; switching the Ladle control still re-seeds. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- revealRows returns one object instead of three near-identical ones, and drops two fields the caller could already derive. `nextShown`/`nextShowAll` become a single `next` that is null exactly when `more` is, so the caller can't reach for a reveal the list isn't offering (that guard was dead code); `onlyFar` was `more === 'farther'` at its one call site, which is inside the empty branch. - The "has a reveal happened" flag is read off the URL rather than held as state, for the same reason the count is: component state resets on the drawer stack's remount, so returning from an event dropped the footer's running total while the URL still said 60 rows were shown. - LoadMore loses its ref surface. Focus stays on the button for free while it survives a press, and the parent already knows from `more` when a press unmounted it — the ref was re-deriving that through the DOM, and dragged a forwardRef + an anchor-arm cast along for a component that only ever renders a button. - useCountrySite goes back inside EmptyResults. Hoisting it to gate the footer put a whole-feed scan + region-index rebuild on the path a NON-empty list renders, and duplicated the empty-state precedence in two places. The offer keeps the top of the empty state; a second way out below it doesn't bury it. - calculateOrder reads the resolved language once instead of per event, and EventListItem's `data-event-row` contract is now asserted — JSX doesn't type-check hyphenated attributes, so a rename would drop focus silently. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Three defects from the code-review pass:
- FilterView's Apply/Clear merged onto the current query and carried `?shown=`
and `?all=1` through. That is the primary way filters change, so the reset
added to `useSetFilters` (the quick-edit pills) missed it: applying a filter
after paging opened the new result set with up to 100 rows in one commit AND
the "> 500 km" segment already revealed, without the press that is the only
thing meant to reveal it.
- `setSearchParams` forwards only the options it is given to `navigate`, so a
bare `{ replace: true }` replaced the entry with a state-less one and
`atlasDepth` fell to 0. One "show more" press was enough to turn the drawer's
X / swipe / Esc from a chronological `navigate(-1)` (restoring the camera)
into a PUSH to the structural parent — and to leave an extra entry in the host
page's history. Carry `location.state`, as FilterView already does. The same
gap was pre-existing in the filter and sort setters; fixed there too, since
this change made it reachable on every press.
- The polite announcement counted the segment on screen, so it read "60 of 60
events" at the exact moment the only control offered 40 more. It now counts
both segments.
Also gives the two reveal stories distinct query strings — sharing one meant
sharing one memoized params object, so a reveal pressed in the first carried
into the second.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The rules that describe what this branch changed: the data-layer note that `getEvents` no longer slices to the nearest 50, the URL-derived slices list gaining the reveal (`?shown=`/`?all=1`) and the setters that must reset it, and the Ladle note that `SeedSearchParams` seeds once per params identity so a story's own writes survive. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The rows render unvirtualized and the fetcher no longer caps the matching set, so `?shown=999999` built the whole feed in one commit — one navigation, inside somebody else's page. `revealFromParams` now clamps at `MAX_REVEAL` (40 presses' worth), `revealRows` re-clamps for every caller, and the control disappears at the ceiling rather than offering a press the clamp would undo on read. Found by the security review pass. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`(a.distance ?? Infinity) - (b.distance ?? Infinity)` is NaN for two placeless events — an invalid Array.sort result. Latent while the nearest-50 slice kept online events off the rendered list; uncapped they always form its tail, so use the `byDistance` helper that already guards it. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The newly revealed rows open exactly where the button was, so the browser's scroll-on-focus yanked the list out from under a mouse user who only pressed a button — `preventScroll` instead. The footer also drops its vertical padding once the button is gone, so the (sr-only, zero-height) live region doesn't leave a blank strip under every fully-revealed list. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The last `setSearchParams(…, { replace: true })` without `state` — and it runs
on every keystroke in the search field, so one character replaced the entry with
a state-less one and dropped its `atlasDepth`. Dismissal (X / swipe / Esc) then
pushed to the structural parent instead of going chronologically back. Matches
the reveal / filter / sort setters, which carry it for the same reason.
Pre-existing, out of #85's scope, but it's the one call site left holding the
invariant this branch documents.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`LoadMore` gets its own story for the three states it renders (more / farther / fully revealed), the last of which is how the collapsed footer is visible at all. `SearchView`'s params memo keys on the CASE rather than its query string, so two cases sharing a query can't share one seed and leak state between each other — the hazard STORYBOOK.md warns about, previously worked around by giving the cases distinct `?q` values. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
a3b625c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://71355e6d.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://feat-load-more-results.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
a3b625c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://321df673.sahajatlas.pages.dev |
| Branch Preview URL: | https://feat-load-more-results.sahajatlas.pages.dev |
The default cut drops from 500 km to 300, and an event whose address country differs from the searched `?cc` is held to half that (`FOREIGN_NEARBY_KM`): distance alone ranks Belgian classes over French ones for someone searching Lille, and the further out the ranking runs the more of it is foreign. Both countries must be known to demote anything, so an online event — which has no address country — is never caught by it. `useSearchCountry` reads `?cc` once for both this and the country-website offer. Also fixes the reveal ceiling, which gated on the requested count rather than the rows actually rendered. `?shown=99999` against a 50-event nearby segment renders 50 rows, not 1000 — but the old gate saw the count at the ceiling and withdrew the control, hiding a whole distant segment behind nothing. Everything now reasons about `rows.length`, which also guarantees every `next` is strictly greater than what's on screen, so no press can be a no-op. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Three changes to the foot of the list: - It pages itself. An IntersectionObserver on the control reveals the next page as it scrolls into view, so the ordinary case — scrolling through nearby results — needs no press. Self-limiting: each reveal inserts a page above the button and pushes it out of view. Armed only while `more === 'more' && !showAll`, so reaching the distant events stays a decision and paging is explicit from there on. The button stays regardless: it remains the keyboard and screen-reader path, which can't depend on a scroll event firing. - The reveal's trigger is passed through, because an auto-reveal must never move focus — the reader only scrolled. - Neutral flat rather than bordered, and the crossing now reads "Show distant events" (across all ten locales) instead of naming the distance, which no longer tells the whole truth now that the boundary depends on the country too. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The list now pages as you scroll, so a toolbar row pinned above it was the one control that scrolled away exactly when a long list made it useful. Both move into the header beside the field they act on, as icon controls with their labels on `aria-label` — four controls share that row. `SortMenu` grows an `iconOnly` trigger (a new `SortIcon`) mirroring `FilterButton`'s. `HEADER_CONTROL` moves from `views/shared` to the Button module: its audience now spans tiers, and the point of the preset is that the whole header row provably renders one set of buttons rather than drifting across the three modules that author it. `ListToolbar` was left with no call sites, so it goes. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Three SearchView cases now cover the reveal: "Paged" (auto-paging as you reach the control), "Distant events" (where that stops and a press takes over), and "Across a border" — same distances, two countries, so only the domestic events lead the list. `mockEventSeries` takes a `country` for the last of those. The state rule gains the two-number boundary and the auto-paging condition; stale "500 km" references go. Closes #85 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Reverts the header move: Filters and Sort go back to their labelled ghost buttons in `ListToolbar`, and `SortMenu` / `SortIcon` / the relocated `HEADER_CONTROL` preset with them. Changing how those controls LOOK was never the point — keeping them on screen was. They now sit in a new `DrawerToolbar` band between the header and the body, outside the scroll container, so a long list scrolls under them instead of carrying them away. That is the whole fix: the list pages as you scroll, so the moment those controls matter most was exactly the moment a body-mounted toolbar had already gone. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Paging is a reading position, not a destination, so it leaves the URL: a reload now starts at the first page and a shared link opens at the top of the results. `?shown=` and `?all=1` are gone, and with them the whole codec. It lands in `useResultsReveal` rather than component state because the drawer stack remounts views — opening an event and coming back would otherwise drop the reader at the top of a list they had paged deep into. The store is keyed by `revealKey` (centre + filters + sort + locale): reading under a different key IS the first page, so a new search, a filter edit or a re-sort resets by construction. That deletes the `resetReveal` calls in `useSetFilters`, `useSetSortOrder` and `FilterView` — three call sites that each had to remember. Two behaviour changes ride along: - The control keeps saying "Show distant events" for every page after the boundary, instead of reverting to "Show more" — everything below it is a distant event, and the old label stopped describing what the press fetched. - The reveal runs inside a `useTransition`, so the button spins and stops taking presses while a page of cards renders. Nothing is fetched; the work is real all the same. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- `revealKey` is built FROM the events query key instead of re-listing its parts, so the centre quantization has one definition and the reveal's notion of "the same search" can't drift from the fetch's. Its test moves with it: the quantization contract is now asserted against `eventsQuery`, where it lives. - `revealRows`' `reachable` was a dead conditional — `near`/`far` partition `sorted`, so both branches equalled `sorted.length`. Folded into `total`. - The event's address country goes through `isoCountryCode` like every other country consumer, so a malformed CMS value degrades to "unknown" and is judged on distance alone rather than compared raw. - `EventListItem` is memoized: the results list grows as it pages, and without it every already-read row re-rendered on every press. - Comments that drifted as the branch changed course: the reveal setter no longer touches history state, `?shown`/`?all` no longer exist, and the distance boundary is no longer 500 km. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
From the security review: - `revealKey` encodes structurally (`JSON.stringify`) rather than joining on `|`. The key carries `filtersKey`, which embeds raw URL values — a region slug, language tokens — so a joined key could be forged, and a collision hands one search's reveal count to another. - `parseCenter` range-checks its coordinates. Mapbox's `LngLat` throws outside ±90 latitude and the value reaches `flyTo` straight from the URL, so `?center=0,1000` took the whole widget down to the error boundary — inside somebody else's page. Pre-existing; in scope because the uncapped list made `?center` matter more. - `Intl.DisplayNames` is cached per locale at module level instead of per hook instance. Every list card calls `useLocale`, so a list paged toward the 1000-row ceiling held two ICU objects per row. Also: the empty state names the boundary that actually applied. "No events within 300 km" is false when a cross-border match sits at 200 km and the 150 km foreign limit is what excluded it; `revealRows` now reports the smaller limit, which is true either way. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
From the code review: - The control was `disabled` while a reveal rendered, and a browser unfocuses a disabled element. A keyboard user pressing "Show more" was dropped to <body> for that commit — and re-enabling doesn't bring focus back, so every press silently cost them their place. The focus effect couldn't catch it either: it returns early while the button survives, which is exactly this case. Now `aria-busy` with a spinner and no `disabled`; the parent's `pending` guard is what makes a second press a no-op. - `EventListItem`'s memo couldn't do its job: the card read `?q` through `useSearchParams`, and router context bypasses `memo`. Since the geocoder rewrites `?q` on every keystroke, typing a new search re-rendered every revealed row — hundreds of them, on the interaction most likely to follow a deep list. The searched place is now read once by the container and passed down. - The SearchView story cases shared one `?center`, so they shared a `revealKey` and the module-global store leaked a reveal from one demo into the next. Distinct centres. - A stale `?all=1` fixture and the story docstring left over from the reverted header-controls commit. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- `DrawerToolbar` joins the Drawer's slot list in DESIGN_SYSTEM, with what it is for: a fixed band outside the scroll container, for controls acting on the content below. - The state rule's reveal entry now says the key is built FROM the events query key (one definition of "the same search", shared with the fetch), that the single-key store resets going forward rather than erasing — sorting away and back restores your place — and why the control is never `disabled`. - The components rule gains the rule the memo depends on: a row in a list that grows must take what it needs as props, because router context bypasses `React.memo`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Summary
/searchresults list no longer stops at the 50 nearest matches.getEventsreturns the whole distance-ranked matching set and the list reveals it 25 rows at a time — paging itself as you scroll through nearby results, with no network request per page (the feed was already fetched once and cached).?sort=soonestused to mean "soonest among the 50 nearest"; measured against a live London search, 8 of the 25 first-pagesoonestresults were outside the old nearest-50 pool.Changes
src/lib/shape/reveal.ts(new) —revealRowssegments the sorted set at the distance boundary, slices to the revealed count, and says what the control offers next.revealKeyidentifies the result set, built from the events query key so "the same search" has one definition shared with the fetch.src/config/store.ts(useResultsReveal) +src/hooks/use-reveal.ts— the reveal is session state, not URL state: a reload starts at the first page, but the drawer stack's remount doesn't lose your place. Keyed byrevealKey, so a new search / filter edit / re-sort resets it by construction — no reset call for a caller to forget.src/components/organisms/EventsList/LoadMore.tsx(new) — the control, its IntersectionObserver auto-paging, and a polite live region that outlives the button the last press unmounts.src/components/atoms/Drawer/Drawer.tsx— aDrawerToolbarslot: a fixed band outside the scroll container, so Filters + Sort don't scroll away exactly when a long list makes them useful.src/config/api/fetch.ts—NEAREST_LIMITgone; sorts with the guardedbyDistance(the inline comparator returnedNaNfor two placeless events — latent while the slice kept online events off the list, now they're always its tail).src/components/molecules/EventListItem/— memoized, and takes the searched place as a prop instead of reading?q, so the memo actually holds against the geocoder's per-keystroke URL writes.Verification
Driven in the running widget against the seeded backend (London, 330 matches), and in Ladle for the states the backend couldn't reach:
cc=GB→ 65 nearby vscc=FR→ 52; the 13 British events between 150–300 km are demotedscroller.contains(button) === false)soonestresults were outside the old nearest-50 poolNotes for reviewer
Design call that needs your confirmation — the "< N km" pill is gone. The ticket's open decision C recommended keeping it and accepting it becoming near-permanent. This went further: the cut is a segment the list pages across, signposted only by the button at the foot. An automatic cut rendered as a removable filter pill reads as something the user chose, and a permanently-present pill teaches people to ignore the pill row. Reverting is contained.
Auto-paging reverses a stated decision in the ticket ("Explicit button, not infinite scroll", on the grounds that the drawer body is vaul's drag surface). It was requested during review and works in practice — the button remains for keyboard and screen-reader users, and auto-paging is withheld at the segment boundary and beyond it.
Second design question: with
?sort=soonestand the distant segment revealed, distant events append below the nearby ones rather than interleaving — so "Soonest" stops being globally soonest after the crossing. Inherent to segmenting, but worth a look.Out of scope, fixed anyway:
MapSearch.setQuerywas the lastreplacewithoutstate, droppingatlasDepthon every keystroke; andparseCenterdidn't range-check, so?center=0,1000made Mapbox throw and took the whole widget to the error boundary inside a host page.Reviews: one
/simplifypass (4 agents), one/code-review(11 findings — 6 fixed, the rest dismissed as documented-intent or consistency nits), and a security review (3 Low + 1 pre-existing Low — all 4 fixed; the earlier unbounded-?shown=finding is moot now the count isn't in the URL, re-verified rather than assumed).Closes #85
🤖 Generated with Claude Code