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

Styles are not applied correctly for elements using shadow DOM. #7118

Closed
1 task done
bramkragten opened this issue Jan 2, 2023 · 8 comments
Closed
1 task done

Styles are not applied correctly for elements using shadow DOM. #7118

bramkragten opened this issue Jan 2, 2023 · 8 comments

Comments

@bramkragten
Copy link

bramkragten commented Jan 2, 2023

Reduced Test Case

https://codepen.io/bramkragten/pen/GRBqxvQ

Do you understand that if a reduced test case is not provided, we will intentionally delay triaging of your ticket?

  • I understand

Which connector are you using (React/Angular/etc)?

No connector (vanilla JS)

Bug Description

The styles are added to the global documents head, these styles will not apply to shadow dom's. So if a fullcalendar instance is used inside a shadow dom, it will miss the required styles.

Solution

Introduce a new option, root:

root?: Document | ShadowRoot
If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.

If root is provided, add the styles to that root instead of the global document.

@bramkragten bramkragten changed the title Styles are not applied correctly for elements using shadow dom. Styles are not applied correctly for elements using shadow DOM. Jan 2, 2023
@acerix
Copy link
Member

acerix commented Jan 3, 2023

There's a related issue here although I'm not sure it's still relevant.

#5884

@steverep
Copy link

steverep commented Jan 3, 2023

That issue is basically the opposite problem since @fontface needs to be outside the shadow per their workaround. Since everything is injected to document.head now, that shouldn't be an issue anymore if I'm understanding correctly.

This issue is much more significant as it affects all styles. Getting rid of users having to manually import stylesheets was a breaking change when using a calendar inside a shadow DOM. Before it was possible to just import the styles and include them in the right spot manually.

I would hope this would be an easy fix to just append the styles to calendarElement.getRootNode() instead of assuming the root is document.

@acerix
Copy link
Member

acerix commented Jan 6, 2023

Thanks for the details. As a workaround for now, you could copy the styles from the DOM like this:

https://codepen.io/acerix/pen/mdjOoNB?editors=0010

@arshaw arshaw added this to the v6-api-brainstorm milestone Jan 9, 2023
@arshaw
Copy link
Member

arshaw commented Jan 25, 2023

Queued for release: 1dfc957

@arshaw
Copy link
Member

arshaw commented Jan 31, 2023

@arshaw arshaw closed this as completed Jan 31, 2023
@SimmeNilsson
Copy link

@arshaw But aren't the styles applied to both main document and shadow DOM in your codepen?
Also, if I manually delete the first style block in head of main document, the grid lines disappear from the calendar.

@arshaw
Copy link
Member

arshaw commented Feb 8, 2023

@SimmeNilsson I'd need to investigate further. Can you please create a new ticket?

@SimmeNilsson
Copy link

@arshaw Thanks! Created a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

5 participants