]> git.openstreetmap.org Git - rails.git/commitdiff
don't re-pan the map when selecting another note that is already on the screen
authorMartin Raifer <martin@raifer.tech>
Sun, 16 Feb 2025 09:36:00 +0000 (10:36 +0100)
committerMartin Raifer <martin@raifer.tech>
Sun, 16 Feb 2025 09:45:49 +0000 (10:45 +0100)
fixes a regression in #5679

app/assets/javascripts/index/note.js

index 6a0487aaac21a2622386f66257860975357b833d..7d1d77801150755df189f6118f2bf9b42da99ca3 100644 (file)
@@ -22,16 +22,10 @@ OSM.Note = function (map) {
 
   page.pushstate = page.popstate = function (path, id) {
     OSM.loadSidebarContent(path, function () {
-      initialize(path, id);
-
       var data = $(".details").data();
       if (!data) return;
       var latLng = L.latLng(data.coordinates.split(","));
-      if (!map.getBounds().contains(latLng)) {
-        OSM.router.withoutMoveListener(function () {
-          map.setView(latLng, 15, { reset: true });
-        });
-      }
+      initialize(path, id, map.getBounds().contains(latLng));
     });
   };
 
@@ -39,7 +33,7 @@ OSM.Note = function (map) {
     initialize(path, id);
   };
 
-  function initialize(path, id) {
+  function initialize(path, id, skipMoveToNote) {
     content.find("button[name]").on("click", function (e) {
       e.preventDefault();
       var data = $(e.target).data();
@@ -86,7 +80,7 @@ OSM.Note = function (map) {
         latLng: L.latLng(data.coordinates.split(",")),
         icon: noteIcons[data.status]
       }, function () {
-        if (!hashParams.center) {
+        if (!hashParams.center && !skipMoveToNote) {
           var latLng = L.latLng(data.coordinates.split(","));
           OSM.router.withoutMoveListener(function () {
             map.setView(latLng, 15, { reset: true });