Leaflet/Leaflet

google chrome does not go back to previous position on the map

Opened this issue · 1 comments

  • I've looked at the documentation to make sure the behavior is documented and expected
  • I'm sure this is a Leaflet code issue, not an issue with my own code nor with the framework I'm using (Cordova, Ionic, Angular, React…)
  • I've searched through the issues to make sure it's not yet reported

Steps to reproduce
We use the leaflet moveend event to update the url with query parameters center and zoom. When the user navigates through the browser history with the back and and next buttons, the map goes back to the positions reflected by the url.

This works, except in one case:

  • in Google Chrome,
  • if the user interacts with the map only with the mousewheel or trackpad.

To reproduce the bug, open this page (bug repro) in Google Chrome: francoisromain.github.io/bug-leaflet-chrome.

  1. Reload the page.
  2. Interact with the map only with the mousewheel or trackpad (zoom-in or zoom-out). Don't click-and-drag, and don't use the zoom control-button. The url updates.
  3. Repeat the previous step a few times (Never click-and-drag, and never use the zoom control-button at all).
  4. Click the back button of the browser.

Expected behavior
Clicks on the back button, should bring back to the previous positions of the map.

Current behavior
The first click on the back button goes back to the previous webpage (or blank page).

Environment

  • Leaflet version: 1.5.1
  • Browser (with version): Google Chrome 75
  • OS/Platform (with version): Mac os and windows

Additional context
This works as expected in other browsers: firefox, safari, edge

Minimal example reproducing the issue
https://github.com/francoisromain/bug-leaflet-chrome

  • this example is as simple as possible
  • this example does not rely on any third party code

From https://francoisromain.github.io/bug-leaflet-chrome/:

How to reproduce the bug?

First, something that works

  1. Open this page in Chrome
  2. Interact with the map:
    • [...]

I noticed you don't necessarily have to interact with the map, if you first left-click any area outside the map for example. then use the mousewheel to zoom the map it works as expected too.