fix: remove the duplicated main landmark from the root layout - #110
Merged
joelpeace48-cell merged 1 commit intoAug 30, 2026
Merged
Conversation
app/layout.tsx renders two <main> elements and {children} twice. Every
page therefore renders its entire content twice, and the skip link — whose
target is the second <main> — lands below the duplicate rather than at the
start of the content.
It came from a merge that resolved a conflict in the layout body by
keeping both sides: the analytics branch's <main> and the accessibility
branch's <main id="main" tabIndex={-1}>. Keeping the latter preserves the
skip-link target, and the footer and analytics components move back below
it where they belong.
This is the second time the same block has been broken this way, and
nothing caught it: typecheck and lint are both happy with two <main>
elements, and duplicate landmarks are a best-practice axe rule rather than
a WCAG A/AA one, so the accessibility suite does not fail either.
tests/unit/layout-landmarks.test.ts closes that gap by asserting the
element count and the skip-link wiring at the source. Confirmed it fails
against the current layout rather than passing vacuously.
Contributor
|
Nice job @defimomof2 |
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.
What this changes
Removes the duplicated
<main>element from the root layout, and adds a unit test so the same breakage cannot reachmaina third time.Why
app/layout.tsxonmaincurrently renders two<main>elements and{children}twice:Two consequences, both user-visible:
#main, which is the second element — so a keyboard user activating "Skip to main content" lands below a full duplicate of the page rather than at the start of the content. That is the opposite of what 2.4.1 asks for.It came from a merge that resolved a conflict in the layout body by keeping both sides — the analytics branch's
<main>and the accessibility branch's<main id="main" tabIndex={-1}>. Keeping the latter preserves the skip-link target; the footer and analytics components move back below it, where they were.Why nothing caught it
This is the second time this exact block has been broken this way, and every existing gate is blind to it:
tscand ESLint are both perfectly happy with two<main>elements.landmark-uniqueis an axe best-practice rule, not WCAG A/AA — ande2e/accessibility.spec.tsruns onlywcag2a,wcag2aa,wcag21a,wcag21aa, so the suite stays green.{children}appears once.tests/unit/layout-landmarks.test.tscloses that gap at the source, asserting the element count, the{children}count, and the skip-link wiring (href="#main"has a target that carries bothid="main"andtabIndex={-1}, and sits ahead of the nav). I confirmed it fails against the current layout rather than passing vacuously.A source-level test rather than a DOM one on purpose: the failure mode is a merge splicing the file, and that is exactly what this catches — cheaply, without a browser.
How it was verified
Risk
Very low, and it removes a defect rather than adding behaviour. The only semantic change is that content renders once instead of twice and the skip link reaches the top of it.