Skip to content

fix(ensadmin): preserve connection param only on sidebar navigation#1840

Merged
notrab merged 4 commits intomainfrom
clean-up-ensadmin-nav-links
Mar 30, 2026
Merged

fix(ensadmin): preserve connection param only on sidebar navigation#1840
notrab merged 4 commits intomainfrom
clean-up-ensadmin-nav-links

Conversation

@notrab
Copy link
Copy Markdown
Member

@notrab notrab commented Mar 29, 2026

Lite PR

Tip: Review docs on the ENSNode PR process

Summary

  • Fixed sidebar navigation to only preserve the connection query param, preventing page-specific params like name from leaking between routes.
  • Removed the UseClearUrlParams hook that was working around this issue downstream cc @Y3drk

Why

  • Navigating between pages via the sidebar was carrying all query params forward. For example, inspecting vitalik.eth on /inspect/records and then clicking "Names" would open /name?name=vitalik.eth instead of the empty explore page.

The UseClearUrlParams hook (added in #1453) was a band-aid for this imo. Fixing the root cause in nav-main.tsx makes it unnecessary.


Testing

  • Manual testing: verified sidebar links only carry connection when navigating between routes that use name (e.g. /inspect/records/name, /name => /status).

Notes for Reviewer (Optional)

The original appendQueryParams in nav-main.tsx forwarded all search params to sidebar links and only had a special case for stripping name/strategy when leaving /inspector.

The new version explicitly forwards only connection, which is the only globally-relevant param.


Pre-Review Checklist (Blocking)

  • This PR does not introduce significant changes and is low-risk to review quickly.
  • Relevant changesets are included (or are not required)

notrab added 2 commits March 29, 2026 15:46
…on query param, preventing page-specific params like name from leaking between routes.
… query param, preventing page-specific params like name from leaking between routes
@notrab notrab requested a review from a team as a code owner March 29, 2026 14:50
Copilot AI review requested due to automatic review settings March 29, 2026 14:50
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment Mar 30, 2026 7:53am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
ensnode.io Skipped Skipped Mar 30, 2026 7:53am
ensrainbow.io Skipped Skipped Mar 30, 2026 7:53am

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 29, 2026

🦋 Changeset detected

Latest commit: d013230

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

This PR includes changesets to release 19 packages
Name Type
ensadmin Patch
ensindexer Patch
ensrainbow Patch
ensapi Patch
fallback-ensapi Patch
@ensnode/datasources Patch
@ensnode/ensrainbow-sdk Patch
@ensnode/ensdb-sdk Patch
@ensnode/ensnode-react Patch
@ensnode/ensnode-sdk Patch
@ensnode/ponder-sdk Patch
@ensnode/ponder-subgraph Patch
@ensnode/shared-configs Patch
@docs/ensnode Patch
@docs/ensrainbow Patch
@docs/mintlify Patch
@namehash/ens-referrals Patch
@namehash/namehash-ui Patch
@ensnode/integration-test-env 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

@vercel vercel bot temporarily deployed to Preview – ensnode.io March 29, 2026 14:50 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io March 29, 2026 14:50 Inactive
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 922e0ad4-3bef-47b3-8ac2-23e4060f482e

📥 Commits

Reviewing files that changed from the base of the PR and between c78a960 and d013230.

📒 Files selected for processing (4)
  • .changeset/curvy-fans-begin.md
  • apps/ensadmin/src/app/layout.tsx
  • apps/ensadmin/src/components/nav-main.tsx
  • apps/ensadmin/src/hooks/use-clear-url-params.tsx
💤 Files with no reviewable changes (2)
  • apps/ensadmin/src/app/layout.tsx
  • apps/ensadmin/src/hooks/use-clear-url-params.tsx

📝 Walkthrough

Walkthrough

This PR refactors query parameter handling in the ensadmin sidebar navigation. It removes the UseClearUrlParams hook and its layout usage, replacing it with useRawConnectionUrlParam() in the NavMain component to preserve only the connection query parameter during route transitions.

Changes

Cohort / File(s) Summary
Changesets entry
.changeset/curvy-fans-begin.md
Added patch release entry documenting the fix to sidebar navigation behavior to preserve only the connection query parameter.
Hook removal
apps/ensadmin/src/hooks/use-clear-url-params.tsx
Removed entire UseClearUrlParams hook implementation and its useClearUrlParamsProps interface (~67 lines). Hook previously cleared page-specific query parameters based on allowed paths.
Layout & navigation refactoring
apps/ensadmin/src/app/layout.tsx, apps/ensadmin/src/components/nav-main.tsx
Removed UseClearUrlParams invocation from layout; updated NavMain to replace useSearchParams() with useRawConnectionUrlParam() and retainCurrentRawConnectionUrlParam() for computing navigation link targets.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

ensnode-internal

Poem

🐰 A cleaner path through params so neat,
We hop with just the connection beat,
Farewell to hooks that cleared the way,
The sidebar navigates so sleek today!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing sidebar navigation to preserve only the connection parameter.
Description check ✅ Passed The description follows the template structure with all required sections completed: Summary, Why, Testing, Notes, and Pre-Review Checklist all filled out appropriately.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch clean-up-ensadmin-nav-links

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 29, 2026

Greptile Summary

This PR fixes the root cause of query param leakage during sidebar navigation by rewriting appendQueryParams in nav-main.tsx to forward only the connection param, then removes the now-redundant UseClearUrlParams hook that had been patching the symptom downstream.

Key changes:

  • nav-main.tsx: appendQueryParams now extracts just searchParams.get("connection") and re-encodes it with encodeURIComponent — the previous logic that special-cased /inspector and stripped name/strategy is removed in favour of this simpler, globally correct approach.
  • layout.tsx: UseClearUrlParams component and its import are removed.
  • use-clear-url-params.tsx: Hook file deleted — its sole registered use-case is fully covered by the nav fix.
  • .changeset/curvy-fans-begin.md: Patch changeset added for ensadmin.

The approach is clean and correct: connection is the only globally meaningful param, so building the URL string from only that value (properly encoded) avoids any accidental param bleed between routes.

Confidence Score: 5/5

Safe to merge — the change is a well-scoped fix with no new logic introduced and no remaining P0/P1 issues.

The refactor is straightforward: a complex, fragile special-case in appendQueryParams is replaced by a minimal, explicit forwarding of the single globally-relevant param. encodeURIComponent is correctly applied to the already-decoded value from searchParams.get(). Removal of UseClearUrlParams is fully justified since it only guarded against the exact problem now fixed at the source. No edge cases identified that the new code mishandles.

No files require special attention.

Important Files Changed

Filename Overview
apps/ensadmin/src/components/nav-main.tsx Core fix: appendQueryParams simplified to forward only the connection param, removing special-case /inspector logic and preventing page-specific params from leaking between routes.
apps/ensadmin/src/app/layout.tsx Removes the UseClearUrlParams band-aid component and its import now that the root cause is fixed in nav-main.
apps/ensadmin/src/hooks/use-clear-url-params.tsx Deleted entirely — the hook's only usage (allowedParams={{ name: ["/name"] }}) is no longer needed because sidebar links no longer forward name in the first place.
.changeset/curvy-fans-begin.md Patch-level changeset entry describing the fix — correct package and severity.

Reviews (1): Last reviewed commit: "lint" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes ENSAdmin sidebar navigation so that only the globally-relevant connection query param is preserved across route changes, preventing page-specific params (e.g. name) from leaking between pages. It also removes the downstream workaround hook that was previously clearing URL params at the layout level.

Changes:

  • Update sidebar link building to forward only connection instead of all current search params.
  • Remove UseClearUrlParams usage from the app layout and delete the hook.
  • Add a changeset to publish the behavior change as a patch.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
apps/ensadmin/src/components/nav-main.tsx Restricts preserved query params on sidebar navigation to connection only.
apps/ensadmin/src/app/layout.tsx Removes the layout-level URL param cleanup hook usage.
apps/ensadmin/src/hooks/use-clear-url-params.tsx Deletes the now-unneeded hook implementation.
.changeset/curvy-fans-begin.md Records the ENSAdmin patch change for release/versioning.
Comments suppressed due to low confidence (2)

apps/ensadmin/src/components/nav-main.tsx:48

  • There is already a centralized helper for preserving the connection query param (useRawConnectionUrlParam().retainCurrentRawConnectionUrlParam) and it also avoids edge cases around existing query strings / hash fragments. Reusing that helper here (or otherwise centralizing the connection param key) would prevent duplication and keep connection URL handling consistent across the app.
      const separator = url.includes("?") ? "&" : "?";
      return `${url}${separator}connection=${encodeURIComponent(connection)}`;
    }

    return url;
  };

apps/ensadmin/src/components/nav-main.tsx:51

  • appendQueryParams no longer appends arbitrary query params (it now only preserves the connection param). Renaming it to something like appendConnectionParam/retainConnectionParam would make the intent clearer and reduce confusion for future edits.
      const separator = url.includes("?") ? "&" : "?";
      return `${url}${separator}connection=${encodeURIComponent(connection)}`;
    }

    return url;
  };

  const isActive = (url: UrlString): boolean => {
    const urlPathname = url.split("?")[0];


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

Copy link
Copy Markdown
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@notrab Looks good. Shared 1 small suggestions please feel welcome to merge when ready 👍

@vercel vercel bot temporarily deployed to Preview – ensnode.io March 30, 2026 07:52 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io March 30, 2026 07:52 Inactive
@notrab notrab merged commit 52495c0 into main Mar 30, 2026
15 of 18 checks passed
@notrab notrab deleted the clean-up-ensadmin-nav-links branch March 30, 2026 07:57
@github-actions github-actions bot mentioned this pull request Mar 30, 2026
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.

3 participants