Skip to content

Fix/anchor detail loading flash#383

Open
zinodict121 wants to merge 2 commits into
AnchorNet-Org:mainfrom
zinodict121:fix/anchor-detail-loading-flash
Open

Fix/anchor detail loading flash#383
zinodict121 wants to merge 2 commits into
AnchorNet-Org:mainfrom
zinodict121:fix/anchor-detail-loading-flash

Conversation

@zinodict121

Copy link
Copy Markdown

Fix AnchorDetail loading flash on deactivate

Fixes #277

What changed and why

Updated AnchorDetail to use await refresh() instead of reload() from useAsync after successfully deactivating an anchor.

Previously, calling reload() forced the UI back into a bare loading state, replacing the entire anchor detail card with a spinner and causing a visible layout flash. By using refresh() instead, the anchor data now re-fetches silently in the background, keeping the existing anchor data on screen. This matches the smoother UX consistency established in SettlementDetail's run() function.

Files touched

  • src/components/AnchorDetail.tsx: Replaced reload() with refresh() and added inline documentation explaining the UX reasoning.
  • src/components/AnchorDetail.test.tsx: Added new tests to cover the deactivation happy path and error handling.

Testing

  • Added "deactivates an anchor without flashing a loading spinner": Verifies the happy path of the deactivation flow. It mocks a delayed fetch to assert that during the re-fetch process, the existing anchor data stays visible in the DOM (no "Loading anchor..." text appears) and that the status updates seamlessly to "Inactive" when the fetch resolves.
  • Added "handles deactivation error gracefully": Verifies that if the deregisterAnchor API call rejects, the component correctly catches the error and finishes cleanly.
  • useAsync was not modified. Its existing contract and return types already supported destructing and awaiting refresh().

All 7 tests in AnchorDetail.test.tsx are passing, and test coverage for AnchorDetail.tsx is at 100% across statements, lines, and branches.

Screenshots / Screen Recordings

(Add any relevant screenshots demonstrating the smooth transition here before submitting)

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.

AnchorDetail's deactivate() flashes a full loading spinner via reload() instead of a silent refresh() like SettlementDetail

2 participants