ng-click-outside icon indicating copy to clipboard operation
ng-click-outside copied to clipboard

Accommodate clickoutside detection for elements that are no longer in the DOM after click

Open UrKr opened this issue 6 years ago • 1 comments

Currently, I think Node.contains is used for detecting if the click happened outside of the element. I have a case where the element within the directive's host is replaced after the click. This means that the clicked element is no longer a descendant of the host and the click is treated as a click outside.

There may be another way and I may be missing something, but I think this would be a solution:

Add an option where the target of the click would be obtained like so: document.elementFromPoint(event.clientX, event.clientY); instead of like so: event.target

This would check the element currently under the cursor instead of the one that was there when the click occurred.

UrKr avatar Sep 06 '18 09:09 UrKr

(NOT A SOLUTION) I was able to work around this issue by adding a (click)="$event.stopPropagating()" to stop ng-outside-click from acting on it.

mdentremont avatar May 15 '19 14:05 mdentremont