Skip to content

Collaborator dropdown error message is never cleared after being shown #89

Description

@Alimedhat000

Problem

client/src/hooks/use-collaborators.ts sets error in three places but only ever clears it at the start of a full refetch (setError(null) inside the docId effect, line 27):

  • `Failed to add collaborator` (line 62, add failure)
  • `Failed to remove collaborator` (line 49, remove failure)
  • `Failed to load collaborators` (line 33, fetch failure)

Once any of these is set, the message persists indefinitely for as long as the hook is mounted with the same `docId`:

  1. Successful retry doesn't clear it — `addCollaborator`'s success path (lines 56–59) never calls `setError(null)`, so the banner stays even though the collaborator was actually added.
  2. Closing and reopening the dropdown doesn't clear it — state lives in the hook, which stays mounted with the document.
  3. A successful `removeCollaborator` likewise never clears a previously-set error.

Impact

Users see a stale "Failed to add collaborator" alert next to a collaborator list that visibly does contain the just-added person. Contradictory UI; looks broken.

Fix

Clear the error at the natural transitions:

  • reset `error` at the start of `addCollaborator` / `removeCollaborator` attempts (mirroring what the fetch effect already does), or
  • clear it in each action's success path

Optionally also derive display from the most recent operation only.

Related: the `AddFailureShowsError` story (`collaborators-dropdown.stories.tsx`) exercises the error path but nothing asserts error clearing on recovery — worth adding once fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions