Fix tech report pagination: Hide next/prev links based on actual data, reset to page 1 on filter changes #1094
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.
This PR fixes the tech report pagination issue where the "Next page" link was displayed even when there were no more technologies to show, leading to 400 errors when users clicked on it.
Problem
The pagination logic had two main issues:
last_pageparameter, which defaulted toFalse, meaning the link was always shown regardless of actual data availabilitySolution
The fix involves three key changes:
1. Dynamic Pagination Control in Frontend
Modified
src/js/techreport/utils/data.jsto calculate the actual total pages based on API data and dynamically show/hide pagination links:2. Template Updates for JavaScript Control
Updated
templates/techreport/category.htmlto initially hide pagination links withstyle="display: none;"and let JavaScript control their visibility based on actual data rather than server-side logic.3. Filter Reset to Page 1
Modified
src/js/components/filters.jsto automatically reset to page 1 when any filter changes:Testing
Before/After Behavior
This ensures users have a better experience when browsing tech reports and eliminates the confusing 400 errors from invalid pagination requests.
Fixes #1088.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.