-
Notifications
You must be signed in to change notification settings - Fork 167
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
WebComponentExporter: @CSSImport styles are registered in the head #19700
Labels
BFP
Bugfix priority, also known as Warranty
bug
Impact: Low
Released with Vaadin 23.5.4
Released with Vaadin 24.3.17
Released with Vaadin 24.4.9
Severity: Major
Comments
mcollovati
added
bug
Impact: Low
Severity: Major
BFP
Bugfix priority, also known as Warranty
labels
Jul 17, 2024
The issue was triaged and currently added to the backlog priority queue for further investigation |
The issue was assigned to a developer and is currently being investigated |
tltv
added a commit
that referenced
this issue
Aug 1, 2024
vaadin-bot
pushed a commit
that referenced
this issue
Aug 5, 2024
CssImport annotation with just a value attribute can be injected automatically to shadow root of all exported web components (embedded applications) using Constructable StyleSheets. WebComponentExporter should have a theme to make automation work properly in theme-generator.js. Theme property "autoInjectGlobalCssImports": true in theme.json enable auto injection. Disabled by default. Fixes: #19700 Co-authored-by: Marco Collovati <[email protected]>
vaadin-bot
added a commit
that referenced
this issue
Aug 5, 2024
CssImport annotation with just a value attribute can be injected automatically to shadow root of all exported web components (embedded applications) using Constructable StyleSheets. WebComponentExporter should have a theme to make automation work properly in theme-generator.js. Theme property "autoInjectGlobalCssImports": true in theme.json enable auto injection. Disabled by default. Fixes: #19700 Co-authored-by: Tomi Virtanen <[email protected]> Co-authored-by: Marco Collovati <[email protected]>
tltv
added a commit
that referenced
this issue
Aug 5, 2024
CssImport annotation with just a value attribute can be injected automatically to shadow root of all exported web components (embedded applications) using Constructable StyleSheets. WebComponentExporter should have a theme to make automation work properly in theme-generator.js. Theme property "autoInjectGlobalCssImports": true in theme.json enable auto injection. Disabled by default. Fixes: #19700 Co-authored-by: Marco Collovati <[email protected]>
mcollovati
added a commit
that referenced
this issue
Aug 6, 2024
…9746) CssImport annotation with just a value attribute can be injected automatically to shadow root of all exported web components (embedded applications) using Constructable StyleSheets. WebComponentExporter should have a theme to make automation work properly in theme-generator.js. Theme property "autoInjectGlobalCssImports": true in theme.json enable auto injection. Disabled by default. Fixes: #19700 Co-authored-by: Marco Collovati <[email protected]>
tltv
added a commit
that referenced
this issue
Aug 6, 2024
CssImport annotation with just a value attribute can be injected automatically to shadow root of all exported web components (embedded applications) using Constructable StyleSheets. WebComponentExporter should have a theme to make automation work properly in theme-generator.js. Theme property "autoInjectGlobalCssImports": true in theme.json enable auto injection. Disabled by default. Fixes: #19700 Co-authored-by: Marco Collovati <[email protected]>
mcollovati
pushed a commit
that referenced
this issue
Aug 7, 2024
…9752) CssImport annotation with just a value attribute can be injected automatically to shadow root of all exported web components (embedded applications) using Constructable StyleSheets. WebComponentExporter should have a theme to make automation work properly in theme-generator.js. Theme property "autoInjectGlobalCssImports": true in theme.json enable auto injection. Disabled by default. Fixes: #19700
This ticket/PR has been released with Vaadin 23.5.4. |
This ticket/PR has been released with Vaadin 24.3.17. |
This ticket/PR has been released with Vaadin 24.4.9. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
BFP
Bugfix priority, also known as Warranty
bug
Impact: Low
Released with Vaadin 23.5.4
Released with Vaadin 24.3.17
Released with Vaadin 24.4.9
Severity: Major
Description of the bug
When exposing a part of a vaadin application as a webcomponent via the WebComponentExporter, then all styles loaded via the java @CSSImport annotation (without themefor attribute) are registered in the head of the parent document instead of within the bounds of the webcomponent.
Not only does this leak styles in to the parent document and can thus alter it, it also leads to the absence of those styles in the webcomponent.
The issue can be circumvented by not using @CSSImport and instead importing the css files through @import statements in the themes styles.css file.
But, when using addons (form the vaadin addon directory) those typically also reference their styles via @CSSImport and thus their styling is missing when used in a WebComponentExporter.
Expected behavior
Styles loaded via @CSSImport should be registered within the webcomponent when running as a WebComponentExport webcomponent; and should not be registered in the head of the parent document.
Minimal reproducible example
Try for instance adding the addon
<dependency><groupId>org.vaadin.tatu</groupId><artifactId>twincolselect</artifactId<version>2.5.2</version></dependency>
to a WebComponentExporter.This addon does a @CSSImport at https://github.com/TatuLund/TwinColSelect/blob/ec21083c1502ec8f150a603185be1f6151e45d9a/src/main/java/org/vaadin/tatu/TwinColSelect.java#L73 of https://github.com/TatuLund/TwinColSelect/blob/master/frontend/themes/mytheme/styles.css.
You'll notice these styles of that styles.css are registered in the head of the document and not active within the WebComponentExporter webcomponent.
Versions
The text was updated successfully, but these errors were encountered: