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

ShadowDOM Support Broken #41

Open
dartanian300 opened this issue Jul 15, 2021 · 5 comments
Open

ShadowDOM Support Broken #41

dartanian300 opened this issue Jul 15, 2021 · 5 comments

Comments

@dartanian300
Copy link

In the commit "fixed default context option" (493bf00) the changes made broke shadow dom support. We're currently using this date picker in the shadow dom and the picker is now added to the global document of the page instead of the shadow dom.

The following change in src/js/render.js is the root of the issue.

-	instanceOptions.context.appendChild(calendarDiv);
+	document.body.appendChild(calendarDiv);

This change was originally intended to allow the date picker to be added to any element rather than only the document root. This would allow the picker to be used in shadow dom as well as inside iframes and other areas that aren't in the global document.

Is there a way this functionality can be reinstated?

@mikecoj
Copy link
Owner

mikecoj commented Jul 16, 2021

Hi,

This change was made because MCDatepicker uses one calendar node for all calendar instances.

Before this commit, the calendar node was added only to the context of the first instance.

For example: if you have 2 instances, the first one using document.body as context and the second one shadow root,
in this case, MCDatepicker will append the calendar node only to the document.body (the context of the first instance). The second instance will use its context just to search the node with the id specified in the el option and add a listener to it.

@dartanian300
Copy link
Author

I see. In order to fully support shadow dom the element would need to be inserted there.

Perhaps the package can be modified so that a date picker is inserted into each context? That way you maintain support for multiple pickers while also supporting shadow dom.

@mikecoj
Copy link
Owner

mikecoj commented Jul 16, 2021

Yes, I think it's a good idea!

@vinoth2442
Copy link

Hi @mikecoj any update about this shadow dom support?
This issue can be fixed adding one more options to append the picker to the given Element.
Ex: appendTo : shadowEle

@mikecoj
Copy link
Owner

mikecoj commented Dec 27, 2021

Hi there,
unfortunately, there are no updates on this.

Due to my involvement in other big projects, I had to dedicate more time to them and less time to this one. I hope this will change soon.

If you've found the solution, I'll be happy to receive a PR from you.

Thank you!

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

No branches or pull requests

3 participants