Skip to content

fix: default drafts/published tab so the empty-state create button isn't hidden - #471

Merged
saqibmanan merged 1 commit into
devfrom
fix/empty-state-tab-default-dev
Sep 22, 2026
Merged

saqibmanan merged 1 commit into
devfrom
fix/empty-state-tab-default-dev

Conversation

@saqibmanan

Copy link
Copy Markdown
Contributor

What

navigationTab (the drafts/published filter on the Datasets, UseCases, and Collaboratives dashboard pages) started as null on first paint, because useQueryState('tab', parseAsString) had no default. Each page's empty-state branch only renders the "Add New X" button when navigationTab === 'drafts' — so for any account whose default-filtered list has zero items, the button (and the visually-selected tab) just didn't render on first load. A useEffect already tried to self-correct by calling setNavigationTab('drafts') when null, but effects run after first paint, so it's a race: the URL-update + re-render round-trip usually wins on a fast connection, and loses under real load or a slower query.

Root cause trail

Found while investigating CivicDataSpace-test#103 (test_prv_006/007 flaky under concurrent CI load). That specific case turned out to be a real, separately-fixed backend bug (DataSpaceBackend#199/PR#203) — but chasing the same symptom class turned up test_prv_011_org_create_collaborative timing out the same way, deterministically, every run, concurrent or not, for an account with zero existing collaboratives. Not flakiness — a real zero-item edge case nobody hit before because the usual test accounts have hundreds of existing records.

dataset/ and usecases/ pages share the byte-identical pattern (confirmed by inspection), so any account whose draft-filtered list happens to be empty hits the same wall there too.

Fix

useQueryState('tab', parseAsString.withDefault('drafts')) — same pattern already used in charts/page.tsx and the dataset access page. navigationTab is synchronously 'drafts' on first render, no race. Removed the now-dead null-check in each page's useEffect (state can no longer be null); kept the refetch-on-tab-change behavior.

Verification

  • tsc --noEmit: clean on all three files (10 pre-existing errors elsewhere, in charts/components/ChartsImage.tsx, untouched by this change).
  • eslint: clean on all three files.
  • Not yet verified against a live running instance — that needs local Keycloak/NextAuth setup, out of scope for reaching this fix. Next step: confirm test_prv_002/003/011 go green against a dev deploy of this branch.

…n isn't hidden

navigationTab was 'null' on first paint (useQueryState with no default),
so the empty-state branch's 'navigationTab === '\''drafts'\''' check failed
on the very first render whenever the current filter had zero items --
the Add New button (and the visual tab selection) just didn't render.
A useEffect already tried to self-correct by calling
setNavigationTab('drafts') when null, but that runs after first paint,
so it only closed the gap once the URL update + re-render round-tripped
-- a race that mostly won on a fast/idle connection and mostly lost
under real load or a slow list query.

Root-caused via CivicDataSpace-test#103: test_prv_011_org_create_collaborative
timed out waiting for a button that was never there for an account with
zero existing collaboratives, on every run, concurrent or not -- not
flakiness, a deterministic zero-item edge case. dataset/ and usecases/
pages share the identical pattern (confirmed by inspection) and would
hit the same bug for any account whose default-filtered list is empty.

Fix: useQueryState('tab', parseAsString.withDefault('drafts')), the same
pattern already used in charts/page.tsx and the access page -- navigationTab
is now synchronously 'drafts' on first render, no round-trip needed. Removed
the now-dead null-check in each page's useEffect (the state can no longer be
null) but kept the refetch-on-tab-change behavior.

Verified: tsc --noEmit and eslint clean on all three files, zero new errors
(10 pre-existing errors elsewhere, in charts/components/ChartsImage.tsx,
untouched by this change). Not verified against a live running instance --
that needs local Keycloak/NextAuth setup out of scope for this change;
next step is confirming test_prv_011/002/003 actually go green against a
dev deploy of this.

This branch was successfully deployed

1 active deployment
development — 2a432a94 Deployed Sep 21, 2026 by saqibmanan via build (24.x) #807
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.

1 participant