Skip to content

fix: copy a heading's link without scrolling the page - #775

Merged
rich-iannone merged 2 commits into
mainfrom
fix/copy-link-without-scrolling
Nov 28, 2026
Merged

rich-iannone merged 2 commits into
mainfrom
fix/copy-link-without-scrolling

Conversation

@rich-iannone

Copy link
Copy Markdown
Member

This PR stops the page from moving when you click the copy-link icon beside a heading. The click handler copied the URL but then let the browser follow the #section link so that the address bar would show it, and following it scrolled the page to put the heading at the top and added a history entry.

Now a plain click cancels the link's default navigation once the clipboard is available, and sets the address bar with history.replaceState, which doesn't scroll. The address bar still shows the section's URL, the URL is still copied and the "Link copied!" note still appears, but the page stays where it was and the Back button isn't affected. Without clipboard access, such as on a site served over plain HTTP, the click follows the link as before.

@rich-iannone
rich-iannone merged commit 5e9ad37 into main Nov 28, 2026
5 checks passed
@rich-iannone
rich-iannone deleted the fix/copy-link-without-scrolling branch November 28, 2026 02:29
@github-actions

Copy link
Copy Markdown

📚 Preview this PR's docs locally

Fetch the just-built site and open it in your browser:

# this exact build
great-docs preview --run 46097091795

# or always the latest build for this PR
great-docs preview --pr 775
Auth & tips
  • Requires great-docs: pip install great-docs (or run via pipx/uvx).
  • Auth: run gh auth login then add --use-gh, or set GITHUB_TOKEN (needs Actions: read).
  • Jump to a page: add --path reference/index.html.
  • Latest vs exact: --pr <n> grabs the newest build; --run <id> pins this one.
  • Re-download: --refresh ignores the local cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant