Comment pagination sometimes jumps back to top of page on works, always does so on news posts

Description

You'll need a work and a news post with two or more pages of comments, and you'll need to load those comments without JavaScript.

For a news post, the URL will look like: https://test.archiveofourown.org/admin_posts/###?show_comments=true#comments

For a single chapter work, the URL will look like: https://test.archiveofourown.org/works/###?show_comments=true#comments

For a multi chapter work, the URL will look like: https://test.archiveofourown.org/works/###?show_comments=true&view_full_work=true#comments

What should happen

When you use the pagination to navigate between pages of comments, the page that is loaded should have a comments anchor on the end of its URL, e.g. https://test.archiveofourown.org/admin_posts/###?page=2&show_comments=true#comments, which should position the comment form at the top of the screen (or the kudos section, if you’re using a work).

What does happen

In reality, this never appears to happen with news posts. It sometimes appears to happen with works.

Tested while logged in, with preferences set to show full work by default and not to warn for adult content. It seems more likely to keep the anchor on works rated Explicit, Mature, or Not Rated, but I am not 100% sure that is the key. redsummernight notes that if they access a work while logged out and have to navigate past the adult content warning, the comments anchor is lost on the pagination (i.e. if you start at https://test.archiveofourown.org/works/704022?show_comments=true&view_full_work=true#comments, following “Proceed” takes you to https://test.archiveofourown.org/works/704022?show_comments=true&view_adult=true&view_full_work=true#comments, and then the anchor disappears when following one of the pagination links.)

Just to reiterate, this only applies when loading comments via the URL parameters, not AJAX. That has its own issues ( AO3-5204 ).

Activity

Show:
ticking instant
December 30, 2018, 12:17 AM

I think this is probably the right fix, but I already have more PRs than I’m comfortable with, so I don’t want to submit another one right now:

https://github.com/tickinginstant/otwarchive/commit/b1f835bdde1fc72e76a53cd6b11680735e1efd71

Ariana
September 10, 2019, 8:27 AM

Reproduced the problem with works with one of my own on Beta and then checked the behaviour on Test:

  1. turned off JavaScript

  2. logged out and went to https://archiveofourown.org/chapters/1089522?show_comments=true#comments (last chapter of one of my fics on Beta with 3 pages of comments) and https://test.archiveofourown.org/works/109413 (single-chapter work on Test with 2 pages of comments).

  3. clicked on Comments, which took me down to the comments section and added #comments to the URL.

  4. Navigate to page 2 of the comments. On Beta, the #comment anchor link disappeared from the URL, and I was back at the top of the page. On Test, the anchor remains and when the page refreshes, the browser skips to the comments section so this checks out for works. 👍🏻

Still need to test news posts next

Ariana
September 10, 2019, 10:37 AM

news post
Tested with https://archiveofourown.org/admin_posts/13694 on Beta (400+ comments) and https://test.archiveofourown.org/admin_posts/668 on Staging.
On Beta, loading page 2 of the comments without JavaScript reloads the page without the #comment fragment. On Staging, page 2 loads with the fragment and the browser correctly scrolls down to the top of the comments.

All looks good to me 👍🏻

cosette
September 10, 2019, 6:41 PM

when paging through this test news post’s comments it jumps to the top of the comments 👍
https://test.archiveofourown.org/admin_posts/668

when paging through this test work’s comments it jumps to the top of the comments 👍
https://test.archiveofourown.org/works/625517

DeployedToBeta

Assignee

ticking instant

Reporter

Sarken

Roadmap

Comments

Priority

Medium

Affects versions

Fix versions

Components

FrontEnd

Difficulty

Medium

Milestone

Internal 0.9
Configure