Skip to content

fix: validate ?tab= before trusting it in ContributorDashboardClient - #735

Open
smartcalsystems-sketch wants to merge 1 commit into
MergeFi:mainfrom
smartcalsystems-sketch:fix-dashboard-tab-param-validation-692
Open

smartcalsystems-sketch wants to merge 1 commit into
MergeFi:mainfrom
smartcalsystems-sketch:fix-dashboard-tab-param-validation-692

Conversation

@smartcalsystems-sketch

Copy link
Copy Markdown

Problem

(searchParams.get("tab") as "active" | "completed") || "active" casts whatever string is in the URL without validating it. /dashboard/contributor?tab=foo (or a stale/mistyped bookmark) sets tab = "foo". Since neither Tabs entry's key matches "foo", no tab is aria-selected, no tab has tabIndex=0 (the tablist becomes unreachable by keyboard), and neither tabpanel renders.

Fix

Replace the unchecked cast with an explicit check: only the literal value "completed" selects the completed tab; every other value (including garbage) falls back to "active".

Testing

  • Added a test asserting ?tab=foo falls back to the Active tab being aria-selected.
  • Added a test asserting ?tab=completed is still honored correctly.
  • Full ContributorDashboardClient.test.tsx suite: 7/7 passing (5 pre-existing + 2 new), zero regressions.
  • tsc --noEmit and eslint clean on both changed files.

Closes #692

…loses MergeFi#692)

`(searchParams.get("tab") as "active" | "completed") || "active"` casts
whatever string is in the URL without checking it. /dashboard/contributor
?tab=foo (or a stale/mistyped bookmark) set tab to the literal string
"foo", which is neither "active" nor "completed" -- no Tabs entry matched
it, so no tab was aria-selected, no tab had tabIndex=0 (unreachable by
keyboard), and neither tabpanel rendered.

Now only the literal value "completed" selects the completed tab;
every other value, including garbage, falls back to "active".
@vercel

vercel Bot commented Oct 13, 2026

Copy link
Copy Markdown

@smartcalsystems-sketch is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

ContributorDashboardClient trusts ?tab= without validation — ?tab=foo selects no tab and renders nothing

1 participant