feat: make Load more elements fetch the next page #120
+356
−54
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
"Load more elements" works: it fetches the next page of the search and adds it below the results that are shown. When everything is shown ("Showing N of N") the button is disabled.
Part of #110 (the one issue for making the whole Elements page work, in several pull requests). The filters and the sort are still only drawn.
Stacked on #118 (the base is
117-connect-elements-search, which is stacked on #114). Change the base todevwhen #118 is merged, before merging this.What is in it
fetchMorewithafter: endCursorof the last page. It uses its own query,SearchCatalogMore, which does not ask fortotalCount(the API counts only when it is asked, and the cache keeps the first count). The cache already adds the page to the list of that search (src/lib/apollo/cache.ts), and "Showing X of Y" counts the rows.hasNextPagefalse, so "Showing N of N"), and the count describes why (aria-describedbypoints to it, so a screen reader hears "Showing 36 of 36").aria-busywhile the next page is on its way, so a double click does not fetch the same page twice. It is also disabled while a new search is loading.describeErroris shown in an alert, with "Press the button to try again". The results that are shown stay. The message goes away with the next search.formatTotal). The server stops counting at 1001 (feat: stop counting the matches of a search at 1001 #121, which goes todevon its own: the page shows 1000+ for any count above 1000, so it works with or without it). The catalog has 562 entries, so the real page shows a number today.after).docs/AI_USAGE.md.Testing
npx vitest run: 41 files, 403 tests passed. New: 3 for "1000+" (the number up to 1000, 1000+ above it, in the page and informatTotal), and 7 for the button (the next page with the cursor and the order, no count in the next query, a double click and the loading state, disabled when everything is shown and described by the count, disabled when the last page has come, error and a new try, a new search from the first page). The old test that said "Load more is not connected" is changed.eslint,tsc -bandnpm run buildpass.yurchenko) has the button disabled at once;handspringhas two pages (20, then 36 of 36) and the button is disabled at the end.Open points
🤖 Generated with Claude Code