Skip to content

Commit

Permalink
[dashboard] fix map center change shows unsaved change after clicking…
Browse files Browse the repository at this point in the history
… reset (elastic#213445)

Closes elastic#213444

The problem is setting the view with the globe view may not set the view
to the exact value. For example setting zoom to 1.74 may move the map to
zoom 1.77. PR resolves this problem by adding a margin of error for
comparing zoom differences.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
(cherry picked from commit ea266bc)
  • Loading branch information
nreese committed Mar 7, 2025
1 parent b414e1f commit 3d45f1b
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,16 @@ export function initializeReduxSync({
(nextValue: MapCenterAndZoom) => {
store.dispatch(setGotoWithCenter(nextValue));
},
fastIsEqual,
(a, b) => {
if (!a || !b) {
return a === b;
}

if (a.lat !== b.lat) return false;
if (a.lon !== b.lon) return false;
// Map may not restore reset zoom exactly
return Math.abs(a.zoom - b.zoom) < 0.05;
},
],
openTOCDetails: [
openTOCDetails$,
Expand Down

0 comments on commit 3d45f1b

Please sign in to comment.