[openstreetmap/openstreetmap-website] Remove unnecessary map bounds adjustment on exiting changeset history (PR #6520)

袁立诚 notifications at github.com
Tue Nov 11 05:34:11 UTC 2025


### Issue:

See #6509

Map zooms out unexpectedly when closing Changeset History during zoom animation 

### Cause:

When zooming the map, opening the History sidebar, or clicking a changeset, the moveEndListener is triggered.

Inside moveEndListener, location.pathname is /history, which causes loadFirstChangesets to be called.

loadFirstChangesets then calls updateMap().

Since loadFirstChangesets is asynchronous (due to fetch), if the History sidebar is closed while it is still executing, location.pathname changes to /.

This leads to map.fitBounds() being triggered, causing the map to zoom unexpectedly.

### Solution:

Store whether the current page is /history in a variable isHistory before executing the fetch in loadFirstChangesets() and loadMoreChangesets().

This prevents changes to pathname during the fetch from causing unintended calls to map.fitBounds() and ensures the map does not zoom unexpectedly.
### Screenshots

old version: 

https://github.com/user-attachments/assets/16283fd0-7abb-4b93-ae29-4b356b148b23

new version:

https://github.com/user-attachments/assets/58acd6bf-7c2d-42bc-bba1-c860a1e38bfe
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/6520

-- Commit Summary --

  * Remove unnecessary map bounds adjustment on exiting changeset history

-- File Changes --

    M app/assets/javascripts/index/history.js (12)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/6520.patch
https://github.com/openstreetmap/openstreetmap-website/pull/6520.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6520
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/6520 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20251110/77af99d2/attachment.htm>


More information about the rails-dev mailing list