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:
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.
I agree it's a bug, though it's a very edge case. Could you please let us know why you want to click right mouse button in the middle of drawing? Maybe we can come up with a solution.
It's not part of the application's expected functionality that the user is required/allowed to right-click during drawing. In fact, it's quite the opposite. We would expect right-clicking on the map to be disabled while drawing and then become re-enabled once drawing is done, since the application is providing its own context menu for the map, similarly to this sample.
I wouldn't agree that this is an edge case though, since it is very easily reproducible as users cannot be prevented from performing accidental right-clicks that, in this case, have unfortunate side effects like console errors, duplicate objects (one in map coordinates that scales properly and one in screen coordinates that remains the same size regardless of the zoom level), improper and/or premature closing of shapes etc.
I also noticed that right-click handling is not an issue just for the Draw toolbar but it can be problematic for the Edit toolbar as well. In the aforementioned sample application, try editing a graphic by dragging one of its nodes to a new position and, while doing that, do a right-click. If you then move the graphic out of the way, you will notice that part of its outline stays in place as a non-scalable graphic, which I also think is no longer part of the graphics layer since the latter's "clear" function won't remove it from the screen (at least in our application).
Even though these problems can be acceptable in many cases, in our case not only will the browser console errors make the application look bad during acceptance testing by our client, it will also look bad to the people using it when they realize that accidental right-clicks while drawing can result in a corrupted graphics layer.
It would be great if ESRI could come up with a workaround until these bugs are fixed in one of the next API releases. Obviously, I will also do some investigating myself and share any useful results in here.