justinmanley/Leaflet.Illustrate

Textboxes sometimes get stuck very small while drawing.

Opened this issue · 1 comments

Sometimes, when drawing a textbox, the textbox get stuck at a fixed size while still very small and the map starts to drag. If the user then goes into editing mode, the textbox can be expanded to a usable size - but it's annoying and unintuitive behavior.

This bug can result in lots of textboxes that look like this:

image

It seems that the size of the textbox may be getting set to the textbox minSize. I'm not sure why that fires the draw:created event and enables map dragging again, though.

This bug is present in the demo for version 0.0.2 (http://manleyjster.github.io/Leaflet.Illustrate/examples/0.0.2/simple/), but seems to have become much more pronounced with updates to L.Illustrate.Textbox#setSize in d34ffc706f.

After some testing and experiments, here's what I've concluded:

  • The problem is with instances of L.Rectangle, not L.Illustrate.Textbox, since the boxes get stuck before the draw:created event is fired (and thus before _fireCreatedEvent is called). L.Illustrate.Create.Textbox is designed so that drawing is done with instances of L.Rectangle, and an L.Illustrate.Textbox is not returned until drawing is complete, so this has to be an issue with L.Rectangle.
  • I observed that I sometimes also get this issue with instances of L.Rectangle drawn using L.Draw.Rectangle, which corroborates the hypothesis that the issue lies with L.Rectangle.
  • At the same time, the bug only appears when the L.Illustrate library is loaded and there is an instance of L.Illustrate.Toolbar added to the map. I couldn't get the bug to appear with L.draw alone. This suggests that this is a bug with L.Illustrate.

Questions

Why does this bug only manifest intermittently? It's not an issue with every textbox - just with some. It's seemingly random. Furthermore, this bug occurs at different rates in different environments (it seems to occur less frequently in the version 0.0.2 demo for L.Illustrate than it does for d34ffc706f, and it occurs less frequently with L.Draw.Rectangle than with L.Illustrate.Textbox).