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

Detect target inside a shadow root for clickOutsideHandler #7743

Closed
ywsang opened this issue Jul 29, 2020 · 2 comments · Fixed by #7779
Closed

Detect target inside a shadow root for clickOutsideHandler #7743

ywsang opened this issue Jul 29, 2020 · 2 comments · Fixed by #7779
Labels
squad:core Issue to be handled by the Core team. type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@ywsang
Copy link
Contributor

ywsang commented Jul 29, 2020

📝 Provide a description of the improvement

clickOutsideHandler currently works by checking whether the click target is one of the context elements. However, when the editor is placed in a shadow root, any click events on the editor are retargeted such that they appear to target the entire editor and not a specific element within the editor.

Because of event retargeting, clickOutsideHandler doesn't function as expected when the editor is in a shadow root. For example, clickOutsideHandler is used to detect when a click outside a dropdown view occurs so that the dropdown view can be collapsed. However, in a shadow root, an event clicking on the dropdown view itself is retargeted so that target is not the dropdown view, and the click triggers dropdown view to be closed. Looking at the event's composed path instead of just target can reveal whether the original target included the context element(s).

📃 Other details

Improving this would be a step in supporting running the editor in shadow DOM (#3891), making a Web Component for CKEditor more possible (#1483)!


If you'd like to see this improvement implemented, add a 👍 reaction to this post.

@ywsang ywsang added the type:improvement This issue reports a possible enhancement of an existing feature. label Jul 29, 2020
@Reinmar Reinmar added the squad:core Issue to be handled by the Core team. label Jul 30, 2020
@Reinmar
Copy link
Member

Reinmar commented Jul 30, 2020

Thank you for a detailed issue :) And even more for the PR 😍

Would you be able, perhaps, to add a test to the PR?

@Reinmar Reinmar added this to the iteration 35 milestone Jul 31, 2020
pomek added a commit that referenced this issue Aug 5, 2020
Other (ui): The clickOutsideHandler() function will take into consideration that the editor can be placed in a shadow root while detecting a click. Closes #7743.

Thanks to @ywsang.
@khiemyc
Copy link

khiemyc commented Dec 4, 2020

copy css line dom to shadown dom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
squad:core Issue to be handled by the Core team. type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
3 participants