Pagination resets filters #1

Closed
opened 2024-05-02 20:31:29 +00:00 by frx · 2 comments
Owner

Move pagination logic to script and move between pages passing all needed parameters

Move pagination logic to script and move between pages passing all needed parameters
frx added this to the MVP project 2024-05-02 20:31:29 +00:00
frx added the
bug
label 2024-05-02 20:31:36 +00:00
frx added this to the Courses milestone 2024-05-02 20:35:12 +00:00
frx self-assigned this 2024-05-02 20:35:20 +00:00
frx removed their assignment 2026-07-01 17:23:32 +00:00
hermes was assigned by frx 2026-07-01 17:23:32 +00:00
Collaborator

Issue #1 Resolved — PR #11 Merged

Root cause: Pagination links were generated with only the page parameter, discarding active filter state (school_id, order_by, asc, per_page). Clicking a page link reset all filters to defaults.

Key changes (10 files, +789/-492):

  • Added QueryParams field to Pagination struct with pageURL() helper to preserve filter parameters in pagination URLs
  • Server-side: buildListCoursesQueryParams() encodes active filters into pagination links
  • Client-side: setupPaginationLinks() intercepts pagination clicks, reads current filter state from DOM, builds full URLs with all parameters
  • Added data-paginated, data-base-url, data-current-page attributes to pagination nav for JS targeting

Commits:

  • fix(issue-1): Pagination resets filters

## Issue #1 Resolved — PR #11 Merged **Root cause:** Pagination links were generated with only the `page` parameter, discarding active filter state (school_id, order_by, asc, per_page). Clicking a page link reset all filters to defaults. **Key changes (10 files, +789/-492):** - Added `QueryParams` field to `Pagination` struct with `pageURL()` helper to preserve filter parameters in pagination URLs - Server-side: `buildListCoursesQueryParams()` encodes active filters into pagination links - Client-side: `setupPaginationLinks()` intercepts pagination clicks, reads current filter state from DOM, builds full URLs with all parameters - Added `data-paginated`, `data-base-url`, `data-current-page` attributes to pagination nav for JS targeting **Commits:** - fix(issue-1): Pagination resets filters --- - PR: #11 (merged by @hermes at 2026-07-03T16:19:56Z) - Merge commit: `91c1778` - Issue: #1
Collaborator

Issue #1 Resolved — Merged

Root cause: Pagination links were hardcoded with only the page number, dropping all active filter query parameters (school, sort order, direction, per-page). Navigating to page 2+ reset filters to defaults.

Key changes (10 files, +103/−34):

  • Added QueryParams field to Pagination struct in core.templ with pageURL() helper that appends preserved filter params to page links
  • Server-side: new buildListCoursesQueryParams() in course.go encodes active filters (school_id, order_by, asc, per_page) into the pagination template context
  • Client-side: setupPaginationLinks() in main.templ intercepts pagination clicks, reads current filter state from the DOM, builds full URLs preserving all parameters
  • Added data-paginated/data-base-url/data-current-page attributes to pagination nav for JS targeting

Review feedback: Approved (lgtm) — no changes requested.

Test results: Build and tests passed on the fix/issue-1 branch before merge.


## Issue #1 Resolved — Merged **Root cause:** Pagination links were hardcoded with only the page number, dropping all active filter query parameters (school, sort order, direction, per-page). Navigating to page 2+ reset filters to defaults. **Key changes (10 files, +103/−34):** - Added `QueryParams` field to `Pagination` struct in `core.templ` with `pageURL()` helper that appends preserved filter params to page links - Server-side: new `buildListCoursesQueryParams()` in `course.go` encodes active filters (school\_id, order\_by, asc, per\_page) into the pagination template context - Client-side: `setupPaginationLinks()` in `main.templ` intercepts pagination clicks, reads current filter state from the DOM, builds full URLs preserving all parameters - Added `data-paginated`/`data-base-url`/`data-current-page` attributes to pagination nav for JS targeting **Review feedback:** Approved (lgtm) — no changes requested. **Test results:** Build and tests passed on the fix/issue-1 branch before merge. --- - PR: #11 (merged by @hermes at 2026-07-03T16:19:56Z) - Merge commit: `91c1778` - Changes: 10 files (+103/−34) - Issue: #1
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: frx/kurious#1
No description provided.