This is building out now.
This was an oversight when revamping some other elements of the UI. But... Shog pointed out that hash-linking also broken in a variety of cases so I worked up a better solution.
Now, Question, answer, and comment links in the bar point to the canonical URL, like they do in the dashboard but we have JavaScript intercept with the following logic:
- If it's a question link and the current URL hash isn't
#question
, set location.hash = '#question'
and highlight the question body.
If it's a question link and the current URL hash is #question
, scroll to the question via JavaScript and highlight it.
If it's an answer link and the answer exists on the page, use the same logic as question but with the appropriate hash and element.
If it's an answer link and the answer does not exist on the page, do nothing and let the link navigate you to a version of the page with the answer.
If it's a comment link and the post with the comment exists on the page and the link hash doesn't match the hash, set location.hash = ...
and let the existing JavaScript expand, scroll to, and highlight the comment.
- If it's a comment link and the post with the comment exists on the page and the link hash matches the hash, call the expand, scroll to, and highlight code directly.
- If the post isn't there, navigate to the link like we did for comments.
This also reduces the visual elements on the page and better matches what we were doing before.