feat: mark unsaved changes on map title and warn before discarding them - #3742
Draft
BRaimbault wants to merge 2 commits into
Draft
feat: mark unsaved changes on map title and warn before discarding them#3742BRaimbault wants to merge 2 commits into
BRaimbault wants to merge 2 commits into
Conversation
…them Appends " - Edited" to the map title when the current map differs from what was last saved, mirroring the data-visualizer-app UX, and warns before navigating away or closing the tab with unsaved changes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
If the browser Back/Forward buttons revert a blocked navigation instead of the dialog's own Cancel/Leave buttons, the confirm-leave modal was never cleared -- it stayed on screen pointing at a stale location, and acting on it (Cancel or Leave) would navigate further than intended or desync the URL from the rendered map. Clear the pending confirm whenever the listener proceeds unblocked. Also stabilizes two useLoadMap test mocks (useDataEngine, useCachedData) that returned a fresh object per render, which destabilized loadMap's identity and caused its mount-effect to spuriously re-fire and mask this bug in the regression test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Contributor
|
🚀 Deployed on https://pr-3742.maps.netlify.dhis2.org |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Implements DHIS2-XXXXX
Description
Appends " - Edited" to the map title when the current map differs from what was last saved, mirroring data-visualizer-app's UX, and guards against losing that work: an in-app "Discard unsaved changes?" dialog before navigating to a different map, and a native browser prompt before closing the tab.
A
savedMapreducer slice tracks the last-saved snapshot, kept in sync via theMAP_SET/MAP_NEW/MAP_PROPS_SETactions the app already dispatches.isMapDirty()compares the live map against that snapshot using an allowlist of saved-payload fields (reusingvalidLayerProperties/validMapPropertiesfromfavorites.js) rather than a blacklist of "ephemeral" fields — a blacklist missed that layer loaders replace a layer's config wholesale with loaded-only fields right after every map load, which made every map look "Edited" immediately on open during development. The title check is debounced 300ms so rapid changes (e.g. dragging an opacity slider) don't run the comparison on every tick; the navigation guard instead checks on demand only when it matters, so it's never stale.Quality checklist
Add N/A to items that are not applicable.
App.jsx/useLoadMap.js), not the dashboard plugin embedToDos
Known issues
history.back()again, which goes one step further back than intended. Matches data-visualizer-app's own equivalent implementation; not fixed here as it needs a larger navigation-direction-aware rework.Screenshots
supporting images