Skip to content

fix(site): meet 24px target size in the shared Link component - #30844

Merged
chrifro merged 9 commits into
mainfrom
a11y-link-target-size
Nov 10, 2026
Merged

chrifro merged 9 commits into
mainfrom
a11y-link-target-size

Conversation

@chrifro

@chrifro chrifro commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

The shared Link component now reaches the WCAG 2.5.8 minimum target size of 24px without moving any surrounding layout.

Deque flagged every "View details" link in the template builder at 18px tall. These are the registry links on the base-template cards (step 1) and the module cards (step 2). The cards pass className="text-xs", and tailwind-merge then removes the variant's leading-6, so the link falls back to text-xs's 16px line height plus the 18px icon. The default sm variant is also under the minimum, at 20px.

Fix

  • The base Link variant gets py-1 -my-1. The padding grows the element's own box by 4px above and below, and the matching negative margin keeps its margin box, and so the layout, unchanged. axe measures the element's box (getBoundingClientRect), not pseudo-elements, which is why this uses padding instead of a ::before overlay.
  • The hover underline moves from bottom-px to bottom-1.25 (5px), so it stays in the same place under the text.
  • Callers in 14 files passed p-0 (or m-0/mt-*) to drop the base pl-0.5. tailwind-merge would remove py-1 but keep -my-1, which shrinks the layout by 8px, so these callers now use pl-0. Three callers needed margin math: TemplateExampleCard mt-1 becomes mt-0, AgentStatus mt-2 becomes mt-1, and DeploymentBanner (p-3) adds my-0.
  • Two callers changed Link from outside its className. TooltipMessage's [&_a]:mt-2 replaced the top half of -my-1 and becomes [&_a]:mt-1. Vertical margins only apply to the inline-flex Link, not to plain inline anchors. The Provisioners empty state renders <Button asChild><Link>, so its Link sets py-0 my-0 and leaves sizing to the button.
  • A new SmallFocused story puts the enlarged box in a Pixel screenshot.
  • The base variant also gets w-fit. The builder cards render the link inside a flex flex-col parent, which stretched it across the card (202.5px), so the hover underline and focus ring ran the full card width. Now the link is only as wide as its text and icon (91px). In inline and block layout, inline-flex already sized itself to its content, so w-fit only changes links inside flex and grid parents.
  • HelpPopoverLink and HelpPopoverAction get the same w-fit. HelpPopoverLinksGroup is a flex flex-col parent, so the workspace outdated tooltip's "Update" button stretched across the popover (278px). It is now 71px. This also narrows the same links in the agent and sub-agent outdated tooltips, the SSH button popover, and the build options popover. Text position is unchanged.

Intended visible changes: the keyboard focus ring wraps the taller box, 8px taller than before. Links inside flex and grid parents no longer stretch, so their hover underline and focus ring end with the text. Nothing else changes visually.

Expected Pixel diffs: I screenshotted all 602 stories that render Link on main and on this branch. Only three kinds of diffs remain:

  • Stories that leave a link focused show the taller focus ring, for example the ModelForm cost-estimate stories and the new SmallFocused story.
  • LifecyclePageView and OverviewPageView stories are 4px taller. A link at the very bottom of the page extends the document scroll height by its padding, so the screenshot gains 4px of blank space. Content pixels are identical.
  • Flaky stories, such as the terminal canvas and input carets, differ between two runs of the same branch.

Proof

Template builder base-template card, /templates/new/builder. Before is main, after is this branch. The link goes from 202.5 × 18px (stretched across the card) to 91 × 26px (sized to its content). The default state is byte-identical.

State Before After
Default
Hover (underline)
Keyboard focus
Clickable box (debug outline)

For w-fit, I compared all 695 stories that render Link with and without the change. No link text moved, and only the builder's "View details" links narrowed. Every other pixel diff either did not reproduce on a re-run or is under 15px of anti-aliasing noise. The login page's centered "Forgot password?" link stays in the same position.

Workspace outdated tooltip, from the WorkspaceOutdatedTooltip story. Before is main, after is this branch. The "Update" action (HelpPopoverAction) goes from 278 × 24px (stretched across the popover) to 71 × 24px, and the version link (Link) goes from 20px to 28px tall. The dashed outline marks each clickable box.

State Before After
Default
Clickable box (debug outline)

Other Link use cases

The fix lives in the shared component, so every Link gets the larger target. The dashed outline marks each link's clickable box. Without the outline, these stories render identically before and after.

Use case Before After
Templates empty state, "create your own" (16px to 24px)
Deployment banner stats (18px to 26px)
Agent status tooltip, "Troubleshoot" (20px to 28px)

I ran axe target-size and measured every link across all Storybook stories, comparing this branch with its merge base:

Before After
axe violations on the shared Link (843 instances in 601 stories) 24 (all in the template builder) 0
Visible shared Links under 24px tall 245 2 (empty links with no text in AuditLogDescription stories)

axe only flagged the builder links because it exempts small targets that are inline in a sentence or have enough space around them. The other 221 small links met the spacing exception but are now 24px tall regardless. w-fit only changed the width of the builder's "View details" links.

Not in scope: 98 axe target-size violations remain on elements that don't use Link: icon buttons (size-5), the combobox clear button (DEQ-13), and a few hand-styled react-router links in Agents chat tools. These need separate fixes.

axe-core 4.11 target-size on a local dev server:

Page Before After
Builder step 1 (base templates) 10 violations, links 18px tall 0 violations, links 26px tall
Builder step 2 (select modules) 20 violations, links 18px tall 0 violations, links 26px tall

Layout check: for 85 shared Link instances on 10 pages (/templates, /starter-templates, /deployment/licenses, /deployment/overview, /workspaces, /templates/new/builder, /audit, /users, /templates/new, /templates/new?exampleId=docker), each link's content top, margin-box height, and parent height are identical before and after. Builder card heights are unchanged.

Fixes DEQ-124, DEQ-306, DEQ-509, DEQ-462, DEQ-267, DEQ-591, DEQ-252, DEQ-419, DEQ-386, DEQ-390, DEQ-411, DEQ-471, DEQ-331, DEQ-21, DEQ-381, DEQ-14, DEQ-111, DEQ-66, DEQ-274, DEQ-178, DEQ-48, DEQ-248, DEQ-146, DEQ-446, DEQ-374

Decision log
  • Scope. All 25 issues are the same element, the "View details" link in TemplateCard.tsx and ModuleCard.tsx. Both already use the shared Link. The user chose a global component fix over per-card fixes.
  • Why not a pseudo-element hit area. A ::before overlay is clickable and satisfies WCAG, but axe's target-size check reads the element's own bounding rect. The Deque re-scan would still flag it. Padding plus an equal negative margin enlarges the measured box and leaves layout unchanged.
  • Why py-1 and not size-specific padding. Many callers override the font size (text-xs, text-base, text-[length:inherit]), and tailwind-merge drops the variant's leading-* when they do. That makes the content height unpredictable (16 to 24px). A flat 4px each side makes every case at least 24px.
  • Consumer audit. I found every className passed to #/components/Link/Link with a TypeScript AST scan, which also covers multi-line JSX and cn() calls. I then searched for Slot parents (asChild) wrapping Link and for parent descendant selectors that target anchors. Finally, a before/after screenshot comparison of all 602 Storybook stories that render Link caught the tooltip and Button cases that the static scans missed.
  • Not changed. Removing the redundant text-xs overrides on the builder cards and elsewhere is not needed for compliance after this change. I left it out to keep the diff focused.
  • Review. frontend-deep-review (all 8 roles) and frontend-review (FE1 to FE10) were run. Blocking and should-fix findings were fixed: a missed TemplateUpload p-0 caller, an arbitrary bottom-[5px], and a geometry assertion in a play function, which was replaced by the SmallFocused story.

Generated by Coder Agents on behalf of @chrifro.

Add py-1 with a matching -my-1 to the base Link variant so its clickable
box is at least 24px tall (WCAG 2.5.8) without moving surrounding layout.
Callers that reset all padding now reset only the left padding so the
vertical pair stays intact.
@linear-code

linear-code Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

TooltipMessage's descendant margin replaced the top half of Link's
-my-1, and Button asChild merged its sizing with Link's hit-area
padding. Compensate in both callers.
Flex and grid parents stretched the inline-flex Link across the
container, so the hover underline and focus ring spanned the full
width of cards like the template builder's "View details".
@chrifro
chrifro requested a review from aqandrew October 16, 2026 11:47
@chrifro
chrifro marked this pull request as ready for review October 16, 2026 11:47
Comment thread site/src/components/Link/Link.tsx Resolved
Comment thread site/src/components/Link/Link.tsx Resolved
@aqandrew

Copy link
Copy Markdown
Collaborator

Actually, since we're reducing the width of template builder cards' "View details" link to span the width of its text (not the whole card)--shouldn't we do the same with the workspace outdated tooltip's "Update" link?

image

@chrifro

chrifro commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

Done. HelpPopoverAction and HelpPopoverLink now use w-fit, so the "Update" button is only as wide as its content (278px → 71px). This also covers the same links in the agent and sub-agent outdated tooltips, the SSH popover, and the build options popover. Before and after screenshots are in the PR description.

Generated by Coder Agents on behalf of @chrifro.

@chrifro
chrifro requested a review from aqandrew October 30, 2026 10:20
# Conflicts:
#	site/src/pages/DeploymentSettingsPage/LicensesSettingsPage/LicensesSettingsPageView.tsx

@aqandrew aqandrew left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just 2 small nits re: comments, but otherwise lgtm!

# Conflicts:
#	site/src/pages/OrganizationSettingsPage/OrganizationProvisionersPage/OrganizationProvisionersPageView.tsx
@chrifro
chrifro temporarily deployed to main November 9, 2026 09:47 — with GitHub Actions Inactive
@chrifro
chrifro temporarily deployed to main November 9, 2026 12:29 — with GitHub Actions Inactive
# Conflicts:
#	site/src/components/Link/Link.tsx
#	site/src/modules/dashboard/DeploymentBanner/DeploymentBannerView.tsx
@chrifro
chrifro requested a review from a team as a code owner November 10, 2026 13:24
@chrifro
chrifro temporarily deployed to main November 10, 2026 13:24 — with GitHub Actions Inactive
@chrifro
chrifro merged commit 24b21ed into main Nov 10, 2026
26 of 27 checks passed
@chrifro
chrifro deleted the a11y-link-target-size branch November 10, 2026 13:41
@chrifro
chrifro temporarily deployed to main November 10, 2026 13:41 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026

This branch was previously deployed

1 inactive deployment
main — e98f19a0 Deployed Nov 10, 2026 by chrifro via cla #253293
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants