Skip to content

Fix annotation guide unsaved changes & back-navigation#10340

Open
prathamesh-patil-5090 wants to merge 23 commits intocvat-ai:developfrom
prathamesh-patil-5090:fix-10303
Open

Fix annotation guide unsaved changes & back-navigation#10340
prathamesh-patil-5090 wants to merge 23 commits intocvat-ai:developfrom
prathamesh-patil-5090:fix-10303

Conversation

@prathamesh-patil-5090
Copy link
Contributor

PR: Fix annotation guide unsaved changes & back-navigation

Summary

This PR addresses two related user experience issues in the annotation guide editor:

  1. Unsaved changes vulnerability

    • The editor now auto-saves text to browser localStorage as a draft.
    • Draft is restored on revisit and a notification offers to discard it.
    • In-app navigation is blocked via <Prompt> when unsaved changes exist.
    • A beforeunload handler warns on browser refresh or tab close.
    • Draft is cleared after a successful submit.
  2. Incorrect back-button target

    • The "Back" button on the guide page previously used prevLocation from Redux,
      which defaulted to /tasks and /projects regardless of the current item.
    • Now it explicitly navigates to /tasks/<id> or /projects/<id> based on the
      current URL. The unsaved-changes prompt still intercepts this navigation.

Testing steps

  1. Open a task or project and navigate to its annotation guide.
  2. Type text but don’t submit. Try navigating away; confirm the prompt appears.
  3. Confirm draft restoration after refresh, and discard functionality works.
  4. Click the back button and verify it sends you to /tasks/<id> or /projects/<id>.
  5. Repeat with unsaved changes to ensure the confirmation dialog appears.

Related issue

Closes #10303 (extracted from #6536).

Additional notes

  • The annotation-guide-page component was updated extensively; please review carefully.
  • A new changelog fragment has been added at changelog.d/20260308_annotation_guide_draft.md.

Test

Screencast.from.2026-03-09.00-15-09.webm

prathamesh-patil-5090 and others added 23 commits November 23, 2025 15:36
Refactor not found components to use a common handleReturn function for navigation.
Remove console log for history length in TaskNotFoundComponent.
Added a new 'Return to Previous Page' button with smart fallback navigation.
Updated link for 'Return to Previous Page' button feature.
Updated the link for the 'Return to Previous Page' button in the changelog.
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.

Make unsaved changes in the annotation guide editor more resilient

2 participants