Skip to content

Preserve page anchor when moving between versions#2880

Merged
fingolfin merged 3 commits intoJuliaDocs:masterfrom
langestefan:stay-on-page-v2
Feb 15, 2026
Merged

Preserve page anchor when moving between versions#2880
fingolfin merged 3 commits intoJuliaDocs:masterfrom
langestefan:stay-on-page-v2

Conversation

@langestefan
Copy link
Copy Markdown
Contributor

Closes #2799

Now we:

  • Stay on the right page and the right position when switching versions.
  • This now also works when navigating via the outdated version warning banner.

*Created with the help of Claude. *

Video to demonstrate that it works:
Screencast_20260215_024650.webm

@fingolfin fingolfin added Type: Enhancement Format: HTML Related to the default HTML output labels Feb 15, 2026
Copy link
Copy Markdown
Collaborator

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

Fantastic, thanks for working on this, the changes look sane and you confirmed they work.

We do need a changelog entry, though!

Also, some nitpick remarks. Those are not blockers for merging but perhaps you are willing to consider them.

Comment on lines +61 to +64
if (stable_base.endsWith("/")) {
stable_base = stable_base.slice(0, -1);
}
target_url = stable_base + "/" + page_path;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This removes a slash just to add it back again. How about

Suggested change
if (stable_base.endsWith("/")) {
stable_base = stable_base.slice(0, -1);
}
target_url = stable_base + "/" + page_path;
if (!stable_base.endsWith("/")) {
stable_base = stable_base + "/";
}
target_url = stable_base + page_path;

Comment on lines 50 to 54
@@ -54,11 +54,14 @@ $(document).ready(function () {
target_url = target_url + "/" + page_path;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess the same comment applies here as to the new code

Comment on lines +95 to +99
window.location.href = href;
}
})
.catch(function () {
window.location.href = href;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we try to keep this code as similar to the code in versions.js as possible, to ease future adjustments? To that end, there are two comments in selected range corresponding to the version of the code in versions.js, which could be replicated here perhaps?

And similar for the code which computes base_url_absolute.

Also, how about renaming href to target_href -- that will make the diff slightly larger but really just by one extra line, but will further reduce difference between the two sets of code.

@langestefan
Copy link
Copy Markdown
Contributor Author

thanks @fingolfin ! I think the comments have been addressed, let me know. I also added a changelog entry.

@fingolfin fingolfin merged commit 642db0b into JuliaDocs:master Feb 15, 2026
26 of 29 checks passed
@langestefan langestefan deleted the stay-on-page-v2 branch February 15, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Format: HTML Related to the default HTML output Type: Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: stay on page when changing version

2 participants