Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

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

Open
UrKr opened this issue Sep 6, 2018 · 1 comment

Comments

@UrKr
Copy link

UrKr commented Sep 6, 2018

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.

@mdentremont
Copy link

mdentremont commented May 15, 2019

(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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants