Draw toolbar & right-click issue

Discussion created by ctrigonis on May 14, 2013
Latest reply on May 15, 2013 by ctrigonis

I'm facing some trouble with the draw toolbar when creating graphics like rectangles, circles, ellipses, freehand shapes and, generally, shapes that involve holding down the left mouse button while drawing. The problem is that, if the right mouse button is clicked while drawing the graphic, the browser's context menu pops-up and mouse behavior from that point on becomes inconsistent, i.e. depending on the type of graphic being drawn and on which button is subsequently clicked, the user will most likely end-up with one or more improperly drawn graphics, while, more importantly, the browser's debug console becomes littered with the following error that is generated every time you move the mouse over the map:

Uncaught TypeError: Cannot read property 'spatialReference' of undefined serverapi.arcgisonline.com:34 (Chrome 26.0.1410.64)

TypeError: pt is undefined @ http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/:34 (Firefox 21.0)

SCRIPT5007: Unable to get value of the property 'spatialReference': object is null or undefined (IE 9.0.8112.16421)

This behavior can be reproduced in this ESRI sample, using the following steps:
1) Click on the "Freehand Polygon" button at the top.
2) Press the left mouse button anywhere on the map and start drawing a simple shape.
3) Without releasing the left mouse button, press the right button.
4) Release both buttons and press the left mouse button again if still in drawing mode.
5) Zoom out and marvel at your masterpiece ;)
6) Check your browser's debug log for errors when moving the mouse cursor over the map.