fix: await async save before closing dirty form modal#5459
fix: await async save before closing dirty form modal#5459AmarTrebinjac wants to merge 3 commits intomainfrom
Conversation
The DirtyFormModal was closing immediately after triggering the onSave callback, without waiting for async mutations to complete. This caused a race condition where navigation could conflict with the mutation's onSuccess navigation handler. Changes: - Make DirtyFormModal's handleSave async and await onSave callback - Add loading state to Save button to prevent double-clicks - Keep modal open if save fails (error handled by mutation's onError) - Update useDirtyForm's onSave type to allow Promise return - Use mutateAsync in useUserExperienceForm for proper Promise handling Closes ENG-616 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@claude This PR does not fix the issue. The back button still overrides the modal and saves the form. Please fix it. |
|
Claude finished @AmarTrebinjac's task in 2m 5s —— View job Fixed back button navigation issue ✓
Root CauseThe issue was that after the save completed in
Fix AppliedModified
Modified
Now when a user clicks the back button with unsaved changes, saves from the modal, the navigation to the back URL completes properly. --- | Branch |
- Wrap onSave in useDirtyForm to handle navigation after save completes - Navigate to pending URL after successful save - Prevent double navigation by checking for pending navigation in useUserExperienceForm - Fixes issue where back button bypassed the modal after save Co-authored-by: Amar Trebinjac <AmarTrebinjac@users.noreply.github.com>
|
@claude It is still not working. Please do a deep, thorough dive through the codebase and fix this issue. |
|
Claude finished @AmarTrebinjac's task in 2m 44s —— View job Fixed browser back button navigation issue ✓
Root CauseThe issue was that Browser back button uses the native browser history API which bypasses Next.js router events entirely. Solution AppliedAdded Changes made to
Now when a user clicks the browser back button or the header back button with unsaved changes, the dirty form modal will properly appear and allow them to save or discard their changes before navigating away. --- | | Branch |
The previous implementation only listened to routeChangeStart event, which doesn't fire for browser back/forward button clicks. Added beforePopState handler to properly intercept browser history navigation and show the dirty form modal. Co-authored-by: Amar Trebinjac <AmarTrebinjac@users.noreply.github.com>
Summary
Closes ENG-616
Created by Huginn 🐦⬛
Preview domain
https://eng-616-back-button-not-showing.preview.app.daily.dev