ng-click-outside
ng-click-outside copied to clipboard
Accommodate clickoutside detection for elements that are no longer in the DOM after click
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.
(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.