openPopup is not working when editable:drawing:end is triggered via keydown -> stopDrawing()
openPopup() is not working, as layer._popup._map is null when editable:drawing:end is triggered via keydown -> stopDrawing()
Given the following code: http://jsbin.com/ratoli/4/edit?html,js,output
Click start to start drawing a polyline.
Stop in the following ways:
- click the last vertex -> popup opens
- click stop -> popup opens
- press ESC -> popup does not open
Upon looking at console.log(e.layer._popup) you can see that _map is null in the 3rd case.
Also, you can see, console.log(e.layer._popup._map) always returns undefined, thus _map is only being processed while this is happening. The added latency of console.logging _popup shows it correctly, while directly printing _map prints undefined in all case.
A possible fix is to put the whole editable:drawing:end in a setTimeout(..., 0) block, commented out in jsbin.
Humm, works for me with ESC while drawing (on FF). Can you try with another browser to narrow the issue?
Sorry, the jsbin was on latest and I uncommented the setInterval to see the effect, and you probably checked that version, I updated the link. Same behaviour on FF and Chrome and Safari / OSX 10.9.
My reasonings for console.log(e.layer._popup._map) being undefined are not valid, as it seems that _map only gets added to _popup on openPopup(), but the effect is still visible on console.log(e.layer._popup).