Skip to content

useOutagesTableState navigates without scroll:false: every filter and page change jumps the table to the top #403

Description

@usmanimamu17-create

---ISSUE---

Problem

All state updates in useOutagesTableState (src/hooks/useOutagesTableState.ts) call router.push without options:

router.push(`?${next.toString()}`);

Next's router.push scrolls to the top of the page by default. Consequences:

  • Scrolling a long incident list is impossible while filtering: an operator on row 40 of the table who opens the severity filter and picks "critical" is yanked to the top; paging to page 3 and then page 2 does the same.
  • The scroll reset compounds the keystroke debounce issue (companion issue): typing a search also resets scroll, so the operator loses their place on every character.
  • The pattern is inconsistent: PaymentsView's drawer uses router.replace(..., { scroll: false }) deliberately, proving the codebase knows the option — the table state simply does not use it.

Root cause

The URL-state helpers were written before the scroll behavior was considered, and scroll: false was never added.

Why this is architecturally hard

  1. The fix is router.push(\?${next}`, { scroll: false })insetParam/setMultiParam— but scroll restoration on the *return* direction (Back) also needsuseEffect`-based scroll restoration if the page wants to preserve the previous position, which the URL-only model does not give for free.
  2. The same helpers exist in the duplicate Dry.tsx copy (companion issue) — the fix must land in the canonical file and the duplicate deleted, or the two drift again.
  3. A test asserting no scroll on navigation requires mocking the router and asserting the options argument — the current tests assert the URL, not the options.

Proposed design

Pass { scroll: false } to both router.push calls, add a test asserting the router receives it, and (optionally) restore scroll position on Back via a scrollRestoration effect.

Acceptance criteria

Service

  • Filter/page changes do not scroll the page.
  • URL state behavior is unchanged.

Tests

  • A test asserts router.push is called with scroll: false.
  • Existing table-state tests pass.

Out of scope

The keystroke debounce (tracked separately) and scroll restoration on Back.

Getting started

npm test -- useOutagesTableState

Good first files to read: src/hooks/useOutagesTableState.ts.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardStellar Waveissue-trackingThird CampaignCampaign: Third Campaignarea/outagesImported campaign issue labelarea/uiImported campaign issue labelpriority/mediumImported campaign issue label

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions