AngularJS - Selection of text triggers ng-click in parent in Chrome

179 Views Asked by At

I am experiencing a problem, to which I currently have no suitable solution:

Having an input field and when selecting the text and the mouse cursor is moved beyond the input field, the ng-click-event on the parent gets triggered when releasing the mouse button. It seems to make sense, since mouseup is triggered, but this is not the behaviour I want.

However, this only occurs in Chrome-Browser, in Firefox, I can't reproduce this issue.

Here's a simple plunker to demonstrate:

https://next.plnkr.co/edit/tNvKNdDRIE9CUqlk?preview

Just try to mark the text and move the mouse beyond the input-field.

  • Expected Behaviour: Background stays Gray.
  • Actual Behaviour: Background gets Green, showing that the ng-click in the background has happened.

How can I fix this?

1

There are 1 best solutions below

0
Yonatan Ayalon On

A working Plnkr

I'm saving the last "mousedown" element - and than decide whether to init Background color change ("$scope.active")