fix: add warning when navigating away from whiteboard with unsaved ch…#166
fix: add warning when navigating away from whiteboard with unsaved ch…#166STRANGENIKHIL wants to merge 2 commits into
Conversation
|
@STRANGENIKHIL is attempting to deploy a commit to the MINHA's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for the PR! The UI changes and the beforeunload logic look great. However, there is an issue with useBlocker. Our application currently uses a traditional (in App.jsx), but useBlocker requires a Data Router (like createBrowserRouter) to function. Using it here will throw a runtime error and crash the Whiteboard page. Could you please remove the useBlocker implementation? You can either rely solely on the beforeunload event for now, or implement a custom prompt for internal route changes. Let me know if you have any questions! |
|
Hey @STRANGENIKHIL, thanks for migrating to createBrowserRouter to support useBlocker , that's a valid approach! However, the second commit introduced a few issues that need to be fixed before this can be merged:
This will throw a TypeError: Cannot read properties of undefined (reading 'pathname') and crash the page when clicking any internal link (like Dashboard) with unsaved changes. Please change it to currentLocation: ({ currentLocation, nextLocation }) =>
|
fixes #104
Description
This Pull Request addresses the issue where users could navigate away from an active whiteboard session and silently lose unsaved progress. It adds browser-level and route-level safety checks to warn the user before leaving, along with a manual Save Board button.
What Changed
hasUnsavedChangesstate inWhiteboard.jsxto track local canvas modifications.hasUnsavedChangestotrue.beforeunloadevent listener to catch browser/tab closing and reloads.useBlockerto catch back-button presses and navbar links (internal SPA navigation).hasUnsavedChangestofalsewhen a whiteboard successfully loads.Why Changed
How to Test
"You have unsaved changes. Are you sure you want to leave?"."Saved Successfully!"banner appears in the top-left area.