Open anselmbradford opened 10 years ago
What I've discovered for this issue:
On first click of the marker, the dispatchEvent
code in https://github.com/codeforamerica/trails-mobile/blob/master/www/js/lib/leaflet/leaflet.js (search for "dispatchEvent" as the code is minified) returns false on the first click, and true on the second click. For this method, MDN says:
The return value is false if at least one of the event handlers which handled this event called preventDefault. Otherwise it returns true.
Other than the false/true value different all other variables surrounding the first and second click appear the same.
When the trail detail view is closed with (https://github.com/codeforamerica/trails-mobile/blob/master/www/js/application/controllers.js#L214), only one click is required. However, when closed using the (X) in the upper-right of the trail detail view (https://github.com/codeforamerica/trails-mobile/blob/master/www/js/application/controllers.js#L592), two clicks are required. Possibly the map needs an initial click to give it focus? However, I experimented with Map.focus()
in closeTrailView()
to no avail.
Additionally, when the the close button (https://github.com/codeforamerica/trails-mobile/blob/master/www/index.html#L134) is refactored to not call closeTrailView()
directly and https://github.com/codeforamerica/trails-mobile/blob/master/www/js/application/controllers.js#L592 is set to the exact same $apply
code a click on the map uses (https://github.com/codeforamerica/trails-mobile/blob/master/www/js/application/controllers.js#L214-L216) two clicks are still required.
First click event profile:
Second click event profile:
Note that second click is a single click, but registers two click events. The first click is a single click as well, but only registers one click, because that click has dispatchEvent returning false.
I've assigned fixing this bug to the v1 release. I'm afraid it may be out of scope given the turnaround we are seeking though.
Steps to repeat issue: