diff --git a/lib/OpenLayers/Handler/Feature.js b/lib/OpenLayers/Handler/Feature.js index d4c65e7872..f2e9741a2a 100644 --- a/lib/OpenLayers/Handler/Feature.js +++ b/lib/OpenLayers/Handler/Feature.js @@ -173,7 +173,13 @@ OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, { * evt - {Event} */ mousedown: function(evt) { - this.down = evt.xy; + // Feature selection is only done with a left click. Other handlers may stop the + // propagation of left-click mousedown events but not right-click mousedown events. + // This mismatch causes problems when comparing the location of the down and up + // events in the click function so it is important ignore right-clicks. + if (OpenLayers.Event.isLeftClick(evt) || OpenLayers.Event.isSingleTouch(evt)) { + this.down = evt.xy; + } return this.handle(evt) ? !this.stopDown : true; }, diff --git a/tests/manual/select-feature-right-click.html b/tests/manual/select-feature-right-click.html new file mode 100644 index 0000000000..edd79d66c3 --- /dev/null +++ b/tests/manual/select-feature-right-click.html @@ -0,0 +1,86 @@ + +
+|
+ Ticket 3404 Test Page +This bug is only triggered by physical right mouse clicks so it is not possible to write + an automated js unit test +When a SelectFeature control and a Navigation control are added to a map the left-click + mousedown events are stopped by a Drag handler before reaching the Feature handler. However, + right-click mousedown events so pass through and reach the Feature handler. +The Feature handler records the xy of + each mousedown and mouseup events so they can be compared in the click event. Because only right-click + mousedown event are received the location of future left-click mouseup events are compared + to the location of the 'stale' right-click mousedown event resulting in the feature not being selected. +Steps to recreate the bug: +
Expected: The point is selected. + |
+ + + | +