Skip to content

fix: improve pagination, linking directly to comments#431

Open
laurelfulford wants to merge 5 commits intotrunkfrom
fix/improve-comment-behaviour
Open

fix: improve pagination, linking directly to comments#431
laurelfulford wants to merge 5 commits intotrunkfrom
fix/improve-comment-behaviour

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford commented Mar 26, 2026

All Submissions:

Changes proposed in this Pull Request:

This PR tweaks the current comment panel approach in the theme to fix a couple UX issues:

  • It makes sure comments can be linked to, even when they're not on the first page
  • It makes the pagination work. It should work within the panel and fetch new comments but worst case, if there's an issue it'll fallback to reloading the page, and reopening the comments to the right page.
  • It also adds links to the comment date so a specific comment is easier to link directly to.

Closes NPPD-1280.

How to test the changes in this Pull Request:

  1. Apply this PR & run npm run build.
  2. Set up your test site to have several comments on a post (20+) - more is better!
  3. Under WP Admin > Settings > Discussion, enable comment pagination and set the comments per page to something reasonably low -- you basically want 3-4+ pages of comments.
CleanShot 2026-03-26 at 11 34 24
  1. Navigate to your post on the front end, scroll to the bottom, and click the Comments button.
  2. In the panel that opens, try paging through the comments using the pagination at the bottom. Confirm the comments load without reloading the whole page.
  3. Pick a random page, and right click on one of the comment's dates (preferably near the bottom). Copy the link, and open a new browser tab and paste it. Confirm the panel opens and it goes to that comment.
  4. While logged in, try commenting. Ensure that the comment posts, and the panel remains open.
  5. While logged in, try replying to a comment, and ensure the comment posts and the panel remains open.
  6. In an incognito window, repeat step 7 and 8. It should ask you for your name and email address, but allow you to comment.
  7. Under WP Admin > Settings > Discussion, check "Users must be registered and logged in to comment"; save.
CleanShot 2026-03-26 at 12 02 45
  1. Back in a fresh incognito window, try to repeat step 7 or 8; confirm you see a message saying you have to log in to comment, and that the link brings you to the /wp-login.php screen. (We may want to hijack the My Account login at a future point but for now WordPress's default behaviour does the trick!).

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves the theme’s slide-in comments panel UX by enabling in-panel comment pagination, preserving deep-linking to individual comments across pages, and making comment timestamps linkable for easier sharing.

Changes:

  • Add fetch-based in-panel pagination and comment form submission, swapping the rendered .wp-block-comments markup without a full page reload.
  • Auto-open the comments panel on paginated comment URLs and on direct #comment-N links, with scroll-to-comment behavior.
  • Enable linking from the comment date by allowing the Comment Date block to render as a link.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/js/front-end/menus/comments.js Adds inline pagination + form submit via fetch, swaps comments block HTML, updates URL, and auto-opens/scrolls for comment deep links.
parts/comments-contents.html Makes the comment date render as a link (to enable direct linking to specific comments).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@laurelfulford
Copy link
Copy Markdown
Contributor Author

Hey @thomasguillot! This could probably use your eyes just to get some feedback on the fade/loading-ish behaviour that you get on pagination 🙂 Just let me know if anything needs tweaking!

@thomasguillot
Copy link
Copy Markdown
Contributor

Screenshot.2026-03-27.at.10.56.24.mp4

This is great and works as it says on the tin. I’m wondering if we should disable scrolling on the main body and keep it limited to the overlay, similar to how the overlay menu works. Right now it feels a bit more annoying than helpful. I think the original idea was to let people view the content and comments at the same time, but realistically that only works on very wide screens, so it’s probably not worth the tradeoff.

@thomasguillot
Copy link
Copy Markdown
Contributor

For the fade-in/loading state, I think this works well since it’s pretty quick. If the load time was longer, we’d probably need a spinner (eg.g newspack-ui) but as it stands this feels fine.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants