fix: make heading anchor links reachable on touch and visible on keyboard focus - closes #2709 - #2711
Open
tiagov8 wants to merge 1 commit into
Open
fix: make heading anchor links reachable on touch and visible on keyboard focus - closes #2709#2711tiagov8 wants to merge 1 commit into
tiagov8 wants to merge 1 commit into
Conversation
…oard focus - closes #2709 Heading anchor icons were hidden with opacity-0 and revealed only via group-hover. Tailwind v4 gates hover variants behind @media (hover: hover), so the reveal could never fire on touch devices - the icon was permanently invisible while still reserving inline-block layout space, producing an unexplained extra line under headings. Adds two variants on top of the existing hover reveal: - pointer-coarse:opacity-100 - always visible where touch is the primary input, so mobile users can reach the anchor at all. - focus-visible:opacity-100 - visible on keyboard focus, fixing a WCAG 2.4.7 failure where focus landed on a fully transparent link. Desktop behaviour is unchanged: headings stay clean and hover-reveal the icon. The group and relative classes are deliberately retained, since group-hover is still in use. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
cc @adamcogan @lukecookssw @kikibianc
Description
✏️
Fixes the heading anchor links (🔗 icon next to
h2/h3/h4) on rule pages. Closes #2709.The problem: the icon is hidden with
opacity-0and revealed withgroup-hover:opacity-100. Tailwind v4 gates hover variants behind@media (hover: hover), confirmed in the live production CSS:So on touch devices the reveal can never fire — the anchor is permanently invisible while still reserving
inline-blocklayout space, which wraps onto a second line and produces an unexplained blank line under headings. Separately, there was nofocus-visiblestate, so keyboard focus landed on a fully transparent link (WCAG 2.4.7 failure).The fix — one line, two variants added on top of the existing hover reveal:
pointer-coarse:opacity-100— permanently visible where touch is the primary input.focus-visible:opacity-100— visible on keyboard focus.Desktop behaviour is unchanged: headings stay clean and hover-reveal the icon.
group relativeis deliberately retained on the heading, sincegroup-hoveris still in use.This is the hybrid option from the issue, chosen over "always visible" to avoid a persistent link icon next to every heading on every rule page.
Verification
Compiled the exact class list with Tailwind CLI v4.2.4 (the version pinned in
package.json) to confirm the utilities generate correctly and in a safe cascade order:All three reveal variants are emitted after the
opacity-0base, so with equal specificity each correctly overrides it. They also cannot conflict with one another, since all three setopacity-100.Known trade-off
On hover-capable desktop devices the invisible icon still reserves layout space, so a heading landing exactly on the wrap boundary can still produce a phantom line there. That is the accepted cost of keeping desktop headings clean — the problem is resolved where it actually bites, on touch. The alternative (always visible) is documented in #2709 if we'd rather eliminate it everywhere.
Note
Supersedes #2710, which implemented the "always visible" option before the direction changed. That PR also stripped
group relativefrom the heading, which would have broken the desktop reveal.Screenshot (optional)
✏️
Not included — the change is a visibility state that needs a real touch device or keyboard focus to demonstrate. Worth a quick check on the deploy preview: open a rule page on a phone and confirm the 🔗 icon is visible next to headings, then tab through on desktop and confirm it appears on focus.
🤖 Generated with Claude Code