mapbox / mapbox/mapbox-gl-geocoder

Suggest list MouseEvent listener duplicates

Open
#532 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug
Dominant language
JavaScript
Stars
388
Forks
181
PR merge metrics
No merged PRs in 30d

Description

The mouse event handlers added to the 'Powered by MapBox' link at the foot of the suggestions list are added again to _footerNode each time the suggestions are redrawn. This leads to an accumulation of many duplicate 'mousedown' and 'mouseup' handlers.

https://github.com/mapbox/mapbox-gl-geocoder/blob/66c236f1f52d69bc2e2b5b8fb3ecc5255fc46acf/lib/index.js#L288-L303

The event handlers should be added to _footerNode only once, outside of typeahead.list.draw()

I noticed this because it was apparent that the _footerNode wasn't being garbage collected in a Single Page App that I was debugging.

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 in lib/index.js at the linked lines 288-303 and inspect how typeahead.list.draw() adds handlers to _footerNode. Trigger repeated suggestions redraws and observe the handler count or footer lifetime. Done means the mousedown and mouseup handlers are attached only once and no longer accumulate on redraw.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.