Skip to content

Add copy feedback to heading anchors#118

Merged
rachaelrenk merged 2 commits into
mainfrom
fix/heading-anchor-copy-feedback
May 20, 2026
Merged

Add copy feedback to heading anchors#118
rachaelrenk merged 2 commits into
mainfrom
fix/heading-anchor-copy-feedback

Conversation

@rachaelrenk

Copy link
Copy Markdown
Contributor

Summary

  • Make Starlight heading anchor icons copy the absolute section URL to the clipboard
  • Preserve the current fragment in the address bar after copy
  • Add temporary "Copied" feedback on the clicked anchor icon

Testing

  • npm --prefix /Users/rachaelrenk/Documents/Warp/docs run typecheck
  • npm --prefix /Users/rachaelrenk/Documents/Warp/docs run build
  • git -C /Users/rachaelrenk/Documents/Warp/docs --no-pager diff --check

Note: npm --prefix /Users/rachaelrenk/Documents/Warp/docs run lint -- src/components/CustomHead.astro could not run locally because trunk is not installed on PATH.

Co-Authored-By: Oz oz-agent@warp.dev

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label May 20, 2026
@vercel

vercel Bot commented May 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 20, 2026 11:22pm

Request Review

@oz-for-oss

oz-for-oss Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

@rachaelrenk

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overview

This PR adds an inline script and global styles to make Starlight heading anchors copy the absolute section URL and show temporary copy feedback.

Concerns

  • Rapid repeat clicks can permanently leave a heading anchor with the temporary "Copied section link to clipboard" accessible label after the visible feedback disappears.
  • The legacy clipboard fallback does not check whether execCommand('copy') actually succeeded, so it can report success even when no copy occurred.

Verdict

Found: 0 critical, 1 important, 1 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread src/components/CustomHead.astro Outdated
textarea.select();

try {
document.execCommand('copy');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 [SUGGESTION] document.execCommand('copy') returns false when the copy fails; reject in that case so the existing catch path preserves normal anchor navigation instead of showing copied feedback for a failed copy.

Co-Authored-By: Oz <oz-agent@warp.dev>
@rachaelrenk rachaelrenk merged commit cb58ee6 into main May 20, 2026
8 checks passed
@rachaelrenk rachaelrenk deleted the fix/heading-anchor-copy-feedback branch May 20, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants