<h3 dir="auto">Issue:</h3>
<p dir="auto">See <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3603013393" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/6509" data-hovercard-type="issue" data-hovercard-url="/openstreetmap/openstreetmap-website/issues/6509/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/issues/6509">#6509</a></p>
<p dir="auto">Map zooms out unexpectedly when closing Changeset History during zoom animation</p>
<h3 dir="auto">Cause:</h3>
<p dir="auto">When zooming the map, opening the History sidebar, or clicking a changeset, the moveEndListener is triggered.</p>
<p dir="auto">Inside moveEndListener, location.pathname is /history, which causes loadFirstChangesets to be called.</p>
<p dir="auto">loadFirstChangesets then calls updateMap().</p>
<p dir="auto">Since loadFirstChangesets is asynchronous (due to fetch), if the History sidebar is closed while it is still executing, location.pathname changes to /.</p>
<p dir="auto">This leads to map.fitBounds() being triggered, causing the map to zoom unexpectedly.</p>
<h3 dir="auto">Solution:</h3>
<p dir="auto">Store whether the current page is /history in a variable isHistory before executing the fetch in loadFirstChangesets() and loadMoreChangesets().</p>
<p dir="auto">This prevents changes to pathname during the fetch from causing unintended calls to map.fitBounds() and ensures the map does not zoom unexpectedly.</p>
<h3 dir="auto">Screenshots</h3>
<p dir="auto">old version:</p>
<p dir="auto"><a href="https://github.com/user-attachments/assets/16283fd0-7abb-4b93-ae29-4b356b148b23">https://github.com/user-attachments/assets/16283fd0-7abb-4b93-ae29-4b356b148b23</a></p>
<p dir="auto">new version:</p>
<p dir="auto"><a href="https://github.com/user-attachments/assets/58acd6bf-7c2d-42bc-bba1-c860a1e38bfe">https://github.com/user-attachments/assets/58acd6bf-7c2d-42bc-bba1-c860a1e38bfe</a></p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/openstreetmap/openstreetmap-website/pull/6520'>https://github.com/openstreetmap/openstreetmap-website/pull/6520</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/6520/commits/333ce6eb7ea35d42ddfd74443ee2debb53fbfdac" class="commit-link">333ce6e</a> Remove unnecessary map bounds adjustment on exiting changeset history</li>
</ul>
<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/6520/files">1 file</a>)</p>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/6520/files#diff-25cab16df4a58e0c8e53d0a0e70d9bbf28ef3beb9e6bf1208234fdeed7515392">app/assets/javascripts/index/history.js</a>
(12)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/6520.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/6520.patch</a></li>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/6520.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/6520.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6520">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMA5SMMRXLIVFNBDDT34FYNHAVCNFSM6AAAAACLXPZTHOVHI2DSMVQWIX3LMV43ASLTON2WKOZTGYYTANZXGYZDENQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLIZHUAJPPG4D2THXUL34FYNHA5CNFSM6AAAAACLXPZTHOWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHNOOASUI.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/6520</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/6520",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/6520",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>