When a marker popup is opened, the auto-pan should be triggered. Afterwards, auto-pan should NOT be triggered and the user should be able to pan away from the popup (provided keepInView=false), even if updates are made to the map while the popup is open.
While a marker popup is opened, auto-pan will be triggered each time a different marker is added or removed on the map.
https://www.webpackbin.com/bins/-Kle4Bvy078Jnxxr1QhZ
Hi,
Please only use GitHub issues to report possible bugs in the library.
You can use the react-leaflet tag in StackOverflow for general questions about it.
@PaulLeCam I'm not sure how this isn't a bug in the library - leaflet itself doesn't exhibit this behavior, I've included reproduction steps, and it seems like a pretty clear mechanic that one of the methods that <Popup /> or <Marker /> is calling in componentDidUpdate is causing Leaflet to re-do the map layout stuff when it shouldn't.
I can investigate this myself if you don't have time, but I'm not sure why you closed the issue without explaining why this isn't a bug in react-leaflet.
@PaulLeCam I have confirmed that vanilla Leaflet dos not exhibit this behavior, meaning this is a possible bug in the library. I'd appreciate it if you could re-open this issue.
@qrohlf Looks like the actual argument that prevents it from panning for your example is autoPan. This defaults to true.
keepInView just forces the popup to stay in the map view.
If you add autoPan={false} to the first Popup component in your example, you'll get the intended behavior.
If you set keepInView={true} with no autoPan argument in the first Popup component in your example, you won't be able to move the map.
@mjclawar That makes sense, it looks like this is an issue with leaflet itself: https://github.com/Leaflet/Leaflet/issues/2937. My mistake.
I'm opening an issue with leaflet since I believe this is undesired behavior (the popup should auto-pan when opened, but adding or removing sibling markers shouldn't re-trigger a popup to pan into view when the user isn't interacting with it at all).
Most helpful comment
@mjclawar That makes sense, it looks like this is an issue with leaflet itself: https://github.com/Leaflet/Leaflet/issues/2937. My mistake.
I'm opening an issue with leaflet since I believe this is undesired behavior (the popup should auto-pan when opened, but adding or removing sibling markers shouldn't re-trigger a popup to pan into view when the user isn't interacting with it at all).