Skip to content

Fix anchor links copy behaviour - #1324

Merged
scudette merged 1 commit into
Velocidex:masterfrom
predictiple:config-ref-fix
Oct 8, 2026
Merged

scudette merged 1 commit into
Velocidex:masterfrom
predictiple:config-ref-fix

Conversation

@predictiple

Copy link
Copy Markdown
Contributor

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

  • 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.

## 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.
@scudette
scudette merged commit 95588f0 into Velocidex:master Oct 8, 2026
5 checks passed
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.

2 participants