Skip to content

fix(connect-wallet): give each network heading its own anchor id - #662

Open
pucedoteth wants to merge 1 commit into
inkonchain:mainfrom
pucedoteth:fix/add-network-anchor-id
Open

fix(connect-wallet): give each network heading its own anchor id#662
pucedoteth wants to merge 1 commit into
inkonchain:mainfrom
pucedoteth:fix/add-network-anchor-id

Conversation

@pucedoteth

Copy link
Copy Markdown

Problem

AddNetworkButton takes a network prop, but its permalink anchor is hardcoded:

<a
  href="#mainnet"
  id="mainnet"
  className="subheading-anchor"
  aria-label="Permalink for this section"
></a>

general/connect-wallet.mdx renders the component twice, once per network:

<AddNetworkButton network="mainnet" heading="Mainnet" />

<AddNetworkButton network="sepolia" heading="Testnet (Sepolia)" />

So both headings emit the same id. From the built page on main:

$ grep -o 'id="mainnet"' .next/server/pages/general/connect-wallet.html | wc -l
2
... Mainnet           <a href="#mainnet" id="mainnet" class="subheading-anchor" ...
... Testnet (Sepolia) <a href="#mainnet" id="mainnet" class="subheading-anchor" ...

Three things follow:

  1. The document carries a duplicate id. That is invalid HTML, and it makes getElementById and :target resolve to whichever element comes first.
  2. The "Testnet (Sepolia)" permalink navigates to Mainnet. The control whose whole purpose is linking to a section links to the wrong one.
  3. The testnet section has no anchor at all, so nothing can link to it.

Fix

Derive both from the network prop:

href={`#${network}`}
id={network}

Mainnet keeps #mainnet, so any existing link or bookmark still resolves, and the testnet heading gets #sepolia.

Verification

Rebuilt and re-checked the same page:

id="mainnet": 1
id="sepolia": 1

... Mainnet           <a href="#mainnet" id="mainnet" ...
... Testnet (Sepolia) <a href="#sepolia" id="sepolia" ...

One of each, on the correct heading.

pnpm run build succeeds. lint:js, lint:mdx and format:js:check all pass. spellcheck:lint fails on main for unrelated reasons (missing dictionary words) which #661 covers; this change adds nothing to it.

Note

This is independent of my two other open PRs here (#654, #661) and touches a different file, so they can be merged in any order.

@pucedoteth
pucedoteth requested a review from a team as a code owner August 31, 2026 21:25
`AddNetworkButton` is parameterised by `network`, but its permalink anchor is
hardcoded:

    <a href="#mainnet" id="mainnet" className="subheading-anchor" ... />

`general/connect-wallet.mdx` renders the component twice, once per network, so
both headings emit the same id. From the built page:

    $ grep -o 'id="mainnet"' .next/server/pages/general/connect-wallet.html | wc -l
    2

    ... Mainnet           <a href="#mainnet" id="mainnet" class="subheading-anchor" ...
    ... Testnet (Sepolia) <a href="#mainnet" id="mainnet" class="subheading-anchor" ...

Three things follow. The document carries a duplicate id, which is invalid
HTML and makes `getElementById` and `:target` resolve to whichever comes
first. The permalink on "Testnet (Sepolia)" navigates to Mainnet, so the
control that exists to link to a section links to the wrong one. And the
testnet section has no anchor at all, so it cannot be linked to.

Derive both from the `network` prop. Mainnet keeps `#mainnet`, so any existing
link still resolves, and the testnet heading gets `#sepolia`.

After the change the built page has one of each, on the right heading:

    ... Mainnet           <a href="#mainnet" id="mainnet" ...
    ... Testnet (Sepolia) <a href="#sepolia" id="sepolia" ...

`lint:js`, `lint:mdx` and `format:js:check` pass, and `pnpm run build`
succeeds. `spellcheck:lint` fails on main for unrelated reasons, covered in
inkonchain#661.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@pucedoteth
pucedoteth force-pushed the fix/add-network-anchor-id branch from f5e7b45 to bd9c038 Compare August 31, 2026 21:42

@kutluhaneth46 kutluhaneth46 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review

Good catch on the duplicate anchors.

Both AddNetworkButton instances were hard-coding id="mainnet" / href="#mainnet", so the Sepolia heading collided with Mainnet in the page DOM and broke deep-links / TOC targets. Using `#${network}` matches the existing network prop ("mainnet" | "testnet") and keeps permalinks unique.

LGTM.

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