Skip to content

fix(admin): introduce RouterLinkButton, fix invalid <Link><Button> HTML nesting - #949

Merged
ascorbic merged 4 commits into
mainfrom
fix/admin-link-button-nesting
May 8, 2026
Merged

ascorbic merged 4 commits into
mainfrom
fix/admin-link-button-nesting

Conversation

@ascorbic

@ascorbic ascorbic commented May 8, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Fixes invalid <a><button> HTML produced by <Link><Button>...</Button></Link> patterns across the admin UI, and introduces a RouterLinkButton component to make this kind of router-aware-button reusable.

<Link><Button> renders as <a><button>, which is invalid HTML — screen readers see two interactive elements, keyboard navigation breaks, and the rendered DOM doesn't match the semantics the developer wrote.

Approach

Two commits, intentionally separated for review clarity:

  1. First commit: Initial fix using the documented <Link className={buttonVariants(...)}> pattern. Also extracts the duplicated "Back to settings" header link into a shared BackToSettingsLink component used by all 7 settings sub-pages, and fixes a raw <button> Retry control in router.tsx ErrorScreen (which was using inline bg-kumo-brand text-white classes that bypassed Kumo's state styling).

  2. Second commit: Introduces a RouterLinkButton component that wraps TanStack Router's <Link> with Kumo button styling (variant, size, shape, icon, className props passing through). Migrates all 16+ <Link className={buttonVariants(...)}> usages — both the ones added in the first commit and 10 pre-existing ones across ContentEditor, ContentList, ContentTypeEditor, ContentTypeList, MenuList, PluginManager, SectionEditor, etc. — to use it. The result: a single, consistent way to render a router-aware button.

Why not Kumo's LinkButton + LinkProvider?

Considered and rejected. Kumo's LinkProvider wires a custom anchor component for LinkButton, but its LinkComponentProps type only accepts plain anchor attrs + optional to: string. TanStack Router's typed routes require params, search, preload, etc. — props that don't fit through Kumo's provider interface. Going via LinkProvider would lose TanStack's type safety, link preloading, active states, and forces a runtime branching adapter.

RouterLinkButton keeps the full TanStack Router Link API intact and just composes Kumo's button-variant classes onto it. Implementation note: I tried using TanStack's createLink() helper first, but it broke the existing test suite (153 failures) because tests mock @tanstack/react-router as a stub anchor and createLink calls useRouter() internally which fails without the real router context. Using <Link> directly inside the wrapper means tests' existing mock substitutes correctly.

Files changed

New:

  • packages/admin/src/components/RouterLinkButton.tsx — the component
  • packages/admin/src/components/settings/BackToSettingsLink.tsx — shared back-to-settings link

Migrated (12 files):

  • Settings pages (ApiTokenSettings, GeneralSettings, SeoSettings, EmailSettings, SocialSettings, SecuritySettings, AllowedDomainsSettings) — use BackToSettingsLink
  • Content editing flow (ContentEditor, ContentList, ContentTypeEditor, ContentTypeList, SectionEditor)
  • Plugin/menu UI (MenuList, PluginManager)
  • Auth flow (SignupPage, InviteAcceptPage)
  • router.tsx — Retry button → Kumo <Button>
  • tests/components/PluginManager.test.tsx — query by role=link instead of role=button (the element is now correctly a link)

Closes #

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.7 (orchestration) + Claude Haiku 4.5 (sub-agents) via OpenCode

Screenshots / test output

No visual change — RouterLinkButton produces the same Tailwind classes as the <Link className={buttonVariants(...)}> pattern. The fix is structural (DOM no longer has <a><button>), affecting screen readers and keyboard navigation rather than visible UI.

Stack: main → #934 (merged) → #937 (merged) → #940 (merged) → this PR → (next: aria-labels) → (next: RTL safety) → (next: semantic tokens) → (last: ESLint enforcement)

ascorbic added 2 commits May 8, 2026 11:43
…tonVariants

<Link><Button>...</Button></Link> renders as <a><button>, which is invalid
HTML and breaks accessibility (screen readers see two interactive elements,
keyboard navigation is wrong). Use the documented pattern:
<Link className={buttonVariants(...)}>.

Extracts the duplicated <Link to="/settings"><Button variant="ghost"
shape="square"><ArrowPrev/></Button></Link> pattern into a shared
BackToSettingsLink component used by all 7 settings sub-pages.

Also fixes router.tsx ErrorScreen Retry button (raw <button> with manual
color classes -> Kumo Button).

Tests in PluginManager updated to query by role=link instead of
role=button (the element is now correctly a link, not a button).
…s usages

RouterLinkButton wraps TanStack Router's <Link> with Kumo button styling,
giving us a single component for router-aware buttons that fixes invalid
<a><button> nesting cleanly. Migrates the previous commit's
<Link className={buttonVariants(...)}> patterns plus 14 existing usages
across ContentEditor, ContentList, ContentTypeEditor, ContentTypeList,
MenuList, PluginManager, SectionEditor, SignupPage, InviteAcceptPage, and
BackToSettingsLink.

Implementation uses <Link> directly (not createLink()) because createLink
breaks tests that mock @tanstack/react-router as a stub anchor — the
mocked Link IS what we use, and our wrapper passes through props.
Copilot AI review requested due to automatic review settings May 8, 2026 10:59
@changeset-bot

changeset-bot Bot commented May 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e262c6d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-perf-coordinator e262c6d May 08 2026, 11:04 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-i18n e262c6d May 08 2026, 11:05 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs e262c6d May 08 2026, 11:05 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground e262c6d May 08 2026, 11:07 AM

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Scope check

This PR touches 21 files. PRs with a broad scope are harder to review. Please confirm the scope hasn't drifted beyond the intended change.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@github-actions github-actions Bot added the size/L label May 8, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache e262c6d May 08 2026, 11:06 AM

@pkg-pr-new

pkg-pr-new Bot commented May 8, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@949

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@949

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@949

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@949

emdash

npm i https://pkg.pr.new/emdash@949

create-emdash

npm i https://pkg.pr.new/create-emdash@949

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@949

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@949

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@949

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@949

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@949

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@949

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@949

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@949

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@949

commit: e262c6d

ascorbic and others added 2 commits May 8, 2026 12:03
Replaces the rambling 'Use Kumo Components' section with a clearer
decision table for Button / LinkButton / RouterLinkButton / buttonVariants,
and documents the new RouterLinkButton helper introduced in this PR.
Net -13 lines.

Copilot AI 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.

Pull request overview

Fixes invalid interactive-element nesting (<a><button>) in the admin UI by introducing a router-aware “button-styled link” component and migrating existing usages to it, improving semantics and accessibility across navigation actions.

Changes:

  • Added RouterLinkButton (TanStack Router <Link> composed with Kumo button styling) and migrated admin “link that looks like a button” usages to it.
  • Extracted a shared BackToSettingsLink and updated settings sub-pages to reuse it.
  • Updated the PluginManager test to assert correct link semantics; replaced a raw retry <button> with Kumo <Button> in the router error screen.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/admin/src/components/RouterLinkButton.tsx New reusable component to render a single <a> styled like a Kumo button for TanStack Router navigation.
packages/admin/src/components/settings/BackToSettingsLink.tsx New shared “Back to settings” control for settings sub-pages using RouterLinkButton.
packages/admin/src/components/settings/ApiTokenSettings.tsx Replaced nested <Link><Button> back control with BackToSettingsLink.
packages/admin/src/components/settings/AllowedDomainsSettings.tsx Replaced nested <Link><Button> back control with BackToSettingsLink.
packages/admin/src/components/settings/EmailSettings.tsx Replaced duplicated back-to-settings header link with BackToSettingsLink.
packages/admin/src/components/settings/GeneralSettings.tsx Replaced duplicated back-to-settings controls (header + sticky header) with BackToSettingsLink.
packages/admin/src/components/settings/SeoSettings.tsx Replaced duplicated back-to-settings controls (header + sticky header) with BackToSettingsLink.
packages/admin/src/components/settings/SecuritySettings.tsx Replaced back-to-settings header control with BackToSettingsLink.
packages/admin/src/components/settings/SocialSettings.tsx Replaced duplicated back-to-settings controls (header + sticky header) with BackToSettingsLink.
packages/admin/src/components/SignupPage.tsx Replaced <Link><Button> login navigation buttons with RouterLinkButton.
packages/admin/src/components/InviteAcceptPage.tsx Replaced <Link><Button> login navigation buttons with RouterLinkButton.
packages/admin/src/components/SectionEditor.tsx Replaced back navigation <Link><Button> patterns with RouterLinkButton.
packages/admin/src/components/PluginManager.tsx Migrated button-styled router links (Marketplace, Settings, etc.) to RouterLinkButton.
packages/admin/src/components/MenuList.tsx Migrated “Edit” router link to RouterLinkButton.
packages/admin/src/components/ContentTypeList.tsx Migrated “New Content Type” and edit icon links to RouterLinkButton.
packages/admin/src/components/ContentTypeEditor.tsx Migrated “Back to Content Types” control to RouterLinkButton.
packages/admin/src/components/ContentList.tsx Migrated “Add New” and row edit icon link to RouterLinkButton.
packages/admin/src/components/ContentEditor.tsx Migrated back-to-list icon link to RouterLinkButton.
packages/admin/src/router.tsx Replaced raw retry <button> styling with Kumo <Button> on the error screen.
packages/admin/tests/components/PluginManager.test.tsx Updated assertions to query the settings control as a link (semantic fix).
.changeset/modern-maps-remain.md Added changeset documenting the admin patch and component introduction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ascorbic
ascorbic merged commit 7aa1897 into main May 8, 2026
40 checks passed
@ascorbic
ascorbic deleted the fix/admin-link-button-nesting branch May 8, 2026 11:21
@emdashbot emdashbot Bot mentioned this pull request May 8, 2026
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