Repository navigation
Fix anchor links copy behaviour - #1324
Merged
Merged
Conversation
## Problem Clicking the chain-link icon next to a config reference item (or a page heading anchor) only jumped to the fragment - nothing was copied to the clipboard, despite `title="Copy link to this item"` on every icon. ## Root cause No click handler for `.anchorlink` ever existed in the repo. Commit 2c47fab's message claims "the click handler copies the full page URL + fragment", but the handler was never committed (likely a casualty of the Velocidex#1313 "0 files changed" PR). The heading-copy script added by Velocidex#1311 (heading-anchor-copy.js) only binds `.subheading-anchor`, so config reference icons had no JS at all - in any revision of the site. ## Fix - heading-anchor-copy.js: widen the delegated click selector to `.subheading-anchor, .anchorlink` so config reference icons share the existing copy logic (plain left-clicks only; modified clicks still navigate untouched). - Add a transient "Link copied to clipboard!" toast so the copy is visible feedback. Position/colours live in custom.css (`.anchor-copy-toast`): fixed below the navbar, dark pill in light mode, inverted (light pill, dark text) in dark mode via the `.dark` selector. One shared element restarts on rapid clicks instead of stacking; `role="status"` + `aria-live="polite"` for screen readers. - No markup changes: generated index.md and main.go untouched. ## Verification Headless Chromium against the dev server: click copies the full URL + fragment (`.../references/#version`), hash navigation still fires, ctrl+click neither copies nor hijacks, `<details>` in `<summary>` does not toggle from icon clicks, heading anchors unchanged, toast fades ~1.8s after the last click, and colours flip live with the Hextra theme toggle in both directions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Clicking the chain-link icon next to a config reference item (or a page heading anchor) only jumped to the fragment - nothing was copied to the clipboard, despite
title="Copy link to this item"on every icon.Root cause
Commit 2c47fab's message claims "the click handler copies the full page URL + fragment", but the handler was never committed (likely a casualty of the #1313 "0 files changed" PR). The heading-copy script added by #1311 (heading-anchor-copy.js) only binds
.subheading-anchor, so config reference icons had no JS at all - in any revision of the site.Fix
.subheading-anchor, .anchorlinkso config reference icons share the existing copy logic (plain left-clicks only; modified clicks still navigate untouched)..anchor-copy-toast): fixed below the navbar, dark pill in light mode, inverted (light pill, dark text) in dark mode via the.darkselector. One shared element restarts on rapid clicks instead of stacking;role="status"+aria-live="polite"for screen readers.