Skip to content

fix: blog pagination reset - implement URL parameter persistence#2291

Open
waygeance wants to merge 3 commits intojson-schema-org:mainfrom
waygeance:fix-blog-pagination-reset
Open

fix: blog pagination reset - implement URL parameter persistence#2291
waygeance wants to merge 3 commits intojson-schema-org:mainfrom
waygeance:fix-blog-pagination-reset

Conversation

@waygeance
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bugfix (pagination state persistence) with minor refactoring.

Issue Number:

Screenshots/videos:

Before:

  • Navigating to page N (e.g., page 3) and refreshing caused the blog to reset to page 1.
  • Pagination state was not reflected in the URL.
  • Hydration mismatch warnings appeared in the console.

After:

  • Pagination state persists via ?page=N.
  • Category filter persists via ?type=Category.
  • No hydration errors.
  • TypeScript compilation passes successfully.
Screencast.from.2026-02-25.16-50-33.webm

If relevant, did you update the documentation?

Not required. This change affects internal state handling and does not modify public documentation or APIs.

Summary

This PR fixes the bug where the blog pagination resets to page 1 after a browser reload.

Previously, pagination state was stored only in component state and was not synchronized with the URL. As a result, refreshing the browser caused the blog to reload on page 1, losing the current pagination context.

Changes made:

  • Initialized currentPage from URL query parameters in pages/blog/index.page.tsx.
  • Added an updateUrl helper function to synchronize pagination and filter state with the browser URL.
  • Updated toggleCategory to reset pagination to page 1 when filters change.
  • Removed server-side URL parameter access to prevent hydration mismatches.
  • Resolved TypeScript errors.
  • Applied Prettier formatting.

This ensures pagination and filter state persist across reloads and eliminates hydration warnings.

Does this PR introduce a breaking change?

No. This change is backward compatible and does not affect any public APIs or external behavior.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

@waygeance waygeance requested a review from a team as a code owner February 27, 2026 21:11
@github-project-automation github-project-automation bot moved this to Ready to review in PR - Triage Group Feb 27, 2026
Copy link
Copy Markdown
Member

@Utkarsh-123github Utkarsh-123github left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @waygeance
Your PR is failing checks and requires fix.
Thanks!

@github-project-automation github-project-automation bot moved this from Ready to review to Changes requested in PR - Triage Group Mar 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 3, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 0cd8cbe

@waygeance
Copy link
Copy Markdown
Contributor Author

Hi @Utkarsh-123github Boss, I have resolved the error please review when you get time ☺️

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4bd72bb) to head (0cd8cbe).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2291   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          672       672           
  Branches       211       211           
=========================================
  Hits           672       672           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@waygeance
Copy link
Copy Markdown
Contributor Author

Any Updates on this @Utkarsh-123github Boss ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Changes requested

Development

Successfully merging this pull request may close these issues.

🐛 Bug: Blog pagination resets to page 1 after browser reload

2 participants