feat: implement unsaved changes modal for navigation blocking #46
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.
feat(ui): add unsaved changes detection and navigation blocking
SUMMARY
This PR adds unsaved changes detection and a modal confirmation dialog to prevent accidental navigation when users have unsaved changes in the dashboard and chart editing pages. This improves user experience by preventing data loss.
Key Changes:
UnsavedChangesModalcomponent that provides a consistent UI for handling unsaved changes across the applicationDashboardPagecomponent when in edit modeExplorePage(chart editing) by comparing current form data with saved/initial stateUnsavedChangesModalinChartListcomponent'sPropertiesModalfor chart metadata editinghistory.block()API to intercept navigation attemptsbeforeunloadevent handling to warn users when closing/refreshing the tab with unsaved changesPropertiesModalto notify parent components about form changes viaonFormChangecallbackDesign Decisions:
url_paramsandextra_form_dataare excluded from change detection as they change frequently but don't represent user editsbeforeunloadprompt is only shown when the custom modal is not already displayed to avoid double promptsAdditional Changes:
.gitignoreto exclude.cursorfilespackage-lock.jsonwith peerDependencies foreslint-plugin-iconsBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
After
TESTING INSTRUCTIONS
Dashboard Edit Mode:
UnsavedChangesModalappearsChart Editing (Explore Page):
UnsavedChangesModalappearsChart Properties Modal (Chart List):
UnsavedChangesModalappearsBrowser Tab Close/Refresh:
Edge Cases:
ADDITIONAL INFORMATION
Has associated issue:
Required feature flags:
Changes UI
Includes DB Migration (follow approval process in SIP-59)
Migration is atomic, supports rollback & is backwards-compatible
Confirm DB migration upgrade and downgrade tested
Runtime estimates and downtime expectations provided
Introduces new feature or API
Removes existing feature or API