Fix/anchor detail loading flash#383
Open
zinodict121 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix AnchorDetail loading flash on deactivate
Fixes #277
What changed and why
Updated
AnchorDetailto useawait refresh()instead ofreload()fromuseAsyncafter 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 usingrefresh()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 inSettlementDetail'srun()function.Files touched
src/components/AnchorDetail.tsx: Replacedreload()withrefresh()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
"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."handles deactivation error gracefully": Verifies that if thederegisterAnchorAPI call rejects, the component correctly catches the error and finishes cleanly.useAsyncwas not modified. Its existing contract and return types already supported destructing and awaitingrefresh().All 7 tests in
AnchorDetail.test.tsxare passing, and test coverage forAnchorDetail.tsxis at 100% across statements, lines, and branches.Screenshots / Screen Recordings
(Add any relevant screenshots demonstrating the smooth transition here before submitting)