Hash/anchor in url prevents further url updates

AI-generated summary

A user, nickvaneijk, reported an issue where using a hash/anchor in a URL on a Discourse-powered website prevents further URL updates. This occurs when navigating to a link with a hash (e.g., _https://mysite.com/my-page#faq_) and then clicking on another topic. The URL does not update. eviltrout suggested that the issue involves JavaScript debugging and tagged joffreyjaffeux for assistance. joffreyjaffeux provided a potential solution with a GitHub pull request: https://github.com/discourse/discourse/pull/7872.

On our discourse powered website we have a separate section which links to certain headings using an anchor/hash in the url, https://mysite.com/my-page#faq

When a user follows this link, the url is updated to that value, but navigating further no longer updates the url.

Is there a reason why the hash prevents any url updates? This currently breaks our app after some links in our app, eg ‘understand.html#understand’

This behavior can also be seen on any discourse powered forum, with a minimal reproducible example below.

  1. go to https://meta.discourse.org/
  2. append #foo to the url, so: https://meta.discourse.org/#foo
  3. Click on any topic, you will see the url does not update

Thanks in advance!

I think this one involves some Javascript debugging and would be best suited for @j.jaffeux.

The issue here is that our router uses hashes in some URLs (in particular, jumping to parts of posts, and I believe faq does it too.) I assume when it’s not a hash we know about somehow it’s breaking stuff, when we should be able to ignore it.

@eviltrout I think that should do it:

https://github.com/discourse/discourse/pull/7872