Skip to content

useSortableData's clearSort is exposed but never invoked by AnchorTable, SettlementTable, or PoolTable #309

Description

@Jagadeeshftw

📌 Description

useSortableData (src/hooks/useSortableData.ts) returns { sorted, sort, requestSort, clearSort }, where clearSort resets the sort state to null in a single call regardless of the current key/direction. All three tables that use the hook — AnchorTable, SettlementTable, and PoolTable (src/components/AnchorTable.tsx, SettlementTable.tsx, PoolTable.tsx) — destructure only { sorted, sort, requestSort }, never clearSort. The only way a user can currently return a table to its unsorted, original order is to click the same active column's header a third time (cycling ascending → descending → unsorted via requestSort), which requires knowing that undocumented three-click cycle and passing back through a descending sort first. clearSort exists specifically to skip that, but no table exposes any control that calls it.

🧩 Requirements and context

  • Add a way for a user to jump directly back to a table's unsorted, original order without needing to click through the descending state first, using the hook's existing clearSort.
  • The existing three-click cycle behavior (asc → desc → unsorted) via requestSort must be unchanged.
  • The affordance should be consistent across AnchorTable, SettlementTable, and PoolTable since all three share the same underlying hook and header component.

🛠️ Suggested execution

  • In src/components/SortableHeader.tsx (or in each table alongside its SortableHeader usages), add a small "Reset sort" control — shown only while a sort is active (sort !== null) — that calls the table's clearSort, wired through in AnchorTable, SettlementTable, and PoolTable.
  • Extend AnchorTable.test.tsx, SettlementTable.test.tsx, and PoolTable.test.tsx with a test that sorts a column, clicks the new reset control, and asserts the table returns to its original, unsorted order without needing three clicks.

✅ Acceptance criteria

  • A user can return any of the three tables to its unsorted order in one action, without cycling through descending first.
  • The existing three-click cycle behavior is unchanged.
  • Test coverage for the new reset affordance across all three tables.

🔒 Security notes

No new attack surface; a client-side UI feature reusing an already-implemented hook capability.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26enhancementNew feature or improvementfrontendFrontend / UI work

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions