fix: Correct target detection for shadow-dom in function isOutsideClick #213
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Problem
Shadom DOM doesn't give you the correct element for
event.target
(it gives you the root for any click you make).In our project (Yandex Nirvana) we use Shadom DOM and because of that the
isOutsideClick
function doesn't work correctly for us which messes up thePopup
component which depends on it.The solution
Use the
composedPath
function which gives you the path to the element you clicked, which works even in Shadow DOM, so we can use thePopup
element without bugs.For reference
You can read about the problem and solution here: https://stackoverflow.com/a/57963850/5892475.
License Agreement
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en.