mapbox / mapbox/mapbox-gl-js

hash updated when calling map.hash.remove()

Open
#11,409 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

when mapOptions.hash = true, calling map.remove() updates the hash

Mapbox Version: mapbox-gl 2.6.1
Browser Version: Chrome 97.0.4692.71

Steps to Trigger Behavior

the issue can be observed on https://mapbox-hash-repro.vercel.app
just before navigating to another page map.remote() gets called too late, resulting in the url of the new page containing the hash

I think the bug is caused by this line https://github.com/mapbox/mapbox-gl-js/pull/6490/files#diff-202fc6c0c71f6ff76d1240e9576278f10cc66ac57fc04faa09ec808e0412aef1R50

this._updateHash() returns a timeout ID, but also updates the hash

Expected Behavior

calling map.remove() shouldn't update the hash

Actual Behavior

calling map.remove() updates the hash

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced pull request diff and inspect the _updateHash and map.remove paths in the Mapbox GL JS source. Reproduce the issue at https://mapbox-hash-repro.vercel.app, then verify that removing a map no longer updates the URL hash before navigation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.