From 3d45f1b6b9a41e66215f8ca510674f98352e9859 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 7 Mar 2025 08:15:21 -0700 Subject: [PATCH] [dashboard] fix map center change shows unsaved change after clicking reset (#213445) Closes https://github.com/elastic/kibana/issues/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 (cherry picked from commit ea266bcd7e90cca036a82165a8c91ea81bc02c0e) --- .../public/react_embeddable/initialize_redux_sync.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/x-pack/platform/plugins/shared/maps/public/react_embeddable/initialize_redux_sync.ts b/x-pack/platform/plugins/shared/maps/public/react_embeddable/initialize_redux_sync.ts index 2d651770d19d9..cd4117745a4ad 100644 --- a/x-pack/platform/plugins/shared/maps/public/react_embeddable/initialize_redux_sync.ts +++ b/x-pack/platform/plugins/shared/maps/public/react_embeddable/initialize_redux_sync.ts @@ -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$,