fix(client): clear stale collaborator dropdown error on retry - #91
Open
Alimedhat000 wants to merge 1 commit into
Open
fix(client): clear stale collaborator dropdown error on retry#91Alimedhat000 wants to merge 1 commit into
Alimedhat000 wants to merge 1 commit into
Conversation
useCollaborators only reset its error inside the initial fetch effect, so a failed add or remove left 'Failed to add/remove collaborator' showing indefinitely — even after a successful retry or closing/reopening the dropdown. Reset the error at the start of each action, mirroring the fetch effect. Adds a browser-mode vitest project for hook-level tests (stories can't exercise API-dependent logic) with coverage for error clearing on successful retries.
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 freeto 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.
Summary
useCollaboratorsonly reset itserrorinside the initial fetch effect, so once a add/remove failed, the alert ("Failed to add collaborator" / "Failed to remove collaborator") persisted indefinitely — even after a successful retry or closing/reopening the dropdown (the hook stays mounted with the document).Fix: reset
errorat the start of eachaddCollaborator/removeCollaboratorattempt, mirroring what the fetch effect already does. Failures still set a fresh message; successes now clear it.Test plan
client/src/hooks/__tests__/use-collaborators.test.tsxrun in a newbrowser-unitvitest browser project (stories can't exercise API-dependent logic). Watched the two recovery tests fail on the unfixed code (stale error asserted), pass after the fix.pnpm --filter client lintandtypecheckclean