0

I noticed this morning that links to comments in the form
https://SE-site/questions/[question-id]/#comment-[id_of_comment] do not work anymore (at least on Firefox and Chrome browsers).

These links used to trigger the default scroll to element with id behavior, but a CSS rule display: contents; on these elements breaks the feature (since they don't have their own box anymore, browsers can't scroll to it).

Example

Links to comments are broken

Affected browsers:

FF37+ and Chrome 58+ with Enable experimental Web Platform features flag.



Note: Links in the form https://SE-site/posts/comments/comment_id do work as intended thanks to js, so this doesn't affect links in in-box messages.

  • Just a dummy test comment. – Kaiido Feb 26 '18 at 3:04
  • @WELZ This concerns only browsers that do support display: contents rule : As of today only FF37+ and chrome with Experimental Web Platform flag. – Kaiido Feb 26 '18 at 3:07
  • Confirmed on latest FF – WELZ Feb 26 '18 at 3:08
  • 1
    Where are you getting links in this format? AFAIK, this has never been officially supported (and certainly breaks if there are more than 5/15 comments or more than a page of answers). Comment permalinks should always contain both the post ID and comment ID in the hash. – Shog9 Feb 26 '18 at 5:13
  • @Shog9 I made it myself since AFAIK there is no easy share comment. And you are right, it would not work when comments are hidden under show n more comments. But still, I guess it's not intended that this CSS rule breaks this default browser behavior. – Kaiido Feb 26 '18 at 5:19
  • 2
    Click the timestamps, @Kaiido – Shog9 Feb 26 '18 at 5:20
4

As I wrote 8 years ago...

this relies on specific aspects of the current implementation, and there's no guarantee they won't change at some point in the future. Don't count on these links being permanent!

In order for comment permalinks to be effective, they have to handle paging and expansion of hidden comments. This can't be done with just an ID in a url fragment, since it requires both server-side and client-side support.

The permalinks that can be obtained by clicking the timestamp on a comment always contain the relevant post ID in the path and fragment. The site serves the correct page, and the client script handles scrolling and highlighting the correct comment (and falls back on scrolling to the correct post if the comment has been deleted).

So stick with that URL format. Even without the styling changes, it's more reliable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .