feat(documents): paginate search with a Pagination control
Frontend side of the /documents pagination work. The page.server.ts load reads ?page= from the URL, forwards page+size=50 to the backend, and exposes the new totalElements/pageNumber/pageSize/totalPages fields on `data`. +page.svelte renders a <Pagination> component below the result list; buildPageHref preserves every filter param and only updates page. The existing triggerSearch debounce flow intentionally drops `page` when any filter changes, so filter edits reset to page 0 automatically. <Pagination> uses plain <a href> links (not goto) so SvelteKit's default scroll restoration scrolls new pages to the top — the expected senior-UX behaviour. Decorative chevrons wrapped in aria-hidden spans, 44px touch targets, focus-visible ring, stacks vertically under 640px. The control hides itself when totalPages ≤ 1. Test coverage: 9 cases on Pagination (label, aria-current, prev/next enable/disable, makeHref invocation, decorative chevron, touch target), plus a filter-reset assertion on +page.svelte (page 5 → edit q → goto URL must drop page=). Adds i18n keys in de/en/es. Manual edit to api.ts pending a post-merge npm run generate:api against a rebuilt dev backend. (#315) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -118,4 +118,20 @@ describe('documents page — URL building', () => {
|
||||
expect.objectContaining({ keepFocus: true, noScroll: true })
|
||||
);
|
||||
});
|
||||
|
||||
it('filter change does not carry the current page — goto URL drops page param', async () => {
|
||||
const { goto } = await import('$app/navigation');
|
||||
vi.mocked(goto).mockClear();
|
||||
|
||||
// User is mid-way through results at page 5; change the search text.
|
||||
render(Page, { data: makeData({ q: 'old', pageNumber: 5 }) });
|
||||
|
||||
const input = page.getByRole('textbox', { name: SEARCH_LABEL });
|
||||
await input.fill('Brief');
|
||||
vi.advanceTimersByTime(500);
|
||||
|
||||
const [url] = vi.mocked(goto).mock.calls[0];
|
||||
expect(url).toContain('q=Brief');
|
||||
expect(url).not.toContain('page=');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user