Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correct target detection for shadow-dom in function isOutsideClick #213

Merged
merged 1 commit into from
Jul 4, 2022
Merged

fix: Correct target detection for shadow-dom in function isOutsideClick #213

merged 1 commit into from
Jul 4, 2022

Conversation

Ruminat
Copy link
Contributor

@Ruminat Ruminat commented Jun 30, 2022

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 the Popup 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 the Popup 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.

@Ruminat Ruminat requested a review from amje as a code owner June 30, 2022 11:17
@yc-ui-bot
Copy link
Contributor

Preview is ready.

@amje
Copy link
Contributor

amje commented Jul 4, 2022

Thanks for fixing this!

@amje amje merged commit 9a285be into gravity-ui:main Jul 4, 2022
@Ruminat Ruminat deleted the fix--`isOutsideClick`-correct-target-detection-for-ShadowDOM branch July 15, 2022 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants