[openstreetmap/openstreetmap-website] Closing the history pane before the changesets are loaded resets the slippy map to the world (#2502)

mmd notifications at github.com
Sat Jan 18 19:59:46 UTC 2020


Ok, I think I know what's going on here:

The following code triggers the asynchronous request to fetch changeset details:

```javascript
    $.ajax({
      url: window.location.pathname,
      method: "GET",
      data: data,
      success: function (html) {
        $("#sidebar_content .changesets").html(html);
        updateMap();
      }
    });
```

Upon success we call updateMap()

```javascript
  function updateMap() {
    changesets = $("[data-changeset]").map(function (index, element) {
      return $(element).data("changeset");
    }).get().filter(function (changeset) {
      return changeset.bbox;
    });

    updateBounds();

    if (window.location.pathname !== "/history") {
      var bounds = group.getBounds();
      if (bounds.isValid()) map.fitBounds(bounds);
    }
  }
```

This issue is caused by `window.location.pathname !== "/history"`: when closing the sidebar before the request finishes, the URL is no longer /history, but /#map. As a consequence we inadvertently set some new bounds.




-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/2502#issuecomment-575933456
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20200118/669bd414/attachment.htm>


More information about the rails-dev mailing list