mapbox / mapbox/mapbox-gl-geocoder
Suggest list MouseEvent listener duplicates
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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