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
[bug]: Duplicate inline <style>s after 'composes' #3547
Comments
Hi @alecarg. Thank you for your report. Add a comment to assign the issue:
|
@magento export issue to JIRA project PWA as Bug |
✅ Jira issue https://jira.corp.magento.com/browse/PWA-2412 is successfully created for this GitHub issue. |
Thanks for the report, @alecarg - we'll investigate! |
I have the same problem and look like it appear after v12.1 upgrade I think It's maybe because addImport use prependSource prependSource(insert) {
return this.spliceSource({ at: 0, insert });
} prependSource adds custom CSS import at the start of a file import ar7HIClasses from "@vendor/pwa-theme-name/lib/components/CartPage/ProductListing/quantity.module.css";
import React, { Fragment } from 'react';
...
import defaultClasses from './quantity.module.css';
...
const classes = useStyle(defaultClasses, ar7HIClasses, props.classes); |
Same issue still reproduced on latest PWA v12.4 |
Hi @alecarg , Can you please provide the css file content to add it in the component which you used for reproducing so that it would be helpful for reproducing the issue? |
As We have no update on this issue Hence we are closing it |
Describe the bug
It would seem like an exact duplicate of the expected <style> tag produced by a venia css file is being added to the DOM. This duplicate is only added after one
composes
a class from that venia css file; if thecomposes
is removed, the duplicate <style> tag disappears. The problem is that the duplicate <style> tag is being added after our own custom <style> tag (resulting from our own custom .css file we've added to our project). Because of specificity, the duplicate <style> tag takes precedence over our own custom <style> tag based on DOM positioning, thus not allowing us to extend venia.See this for the resulting DOM: https://i.ibb.co/3sTQSYJ/Screenshot-2021-11-10-at-09-44-07.png
See this for the resulting styles: https://i.ibb.co/4PCY6zb/Screenshot-2021-11-09-at-11-49-37.png
To reproduce
Steps to reproduce the behavior:
cartTrigger.js
) – similar to https://dev.to/chrisbrabender/simplifying-styling-in-pwa-studio-1ki1 . This means we will be getting this in the browser:.trigger
and compose venia's.trigger
usingcomposes
..trigger
element: 3 set of styles are applied, 2 of which are identical and are applied to the element with varying levels of specificity – as well as the single set of custom styles we added, which does not take precedence over the duplicate styles.Expected behavior
Only 2 set of styles are applied, with the venia ones being less specific than our custom ones.
Screenshots
See above.
Possible solutions
This was working fine in v9~, but broke after we upgraded to v12.0.
It would seem
useStyle
does the sameshallowMerge
asmergeClasses
used to do, so I've discarded that.One thing I found is that altering the order of
defaultClasses
andcustomClasses
(the params fed touseStyle
) yields a different result: the duplicate <style> tag is added, but the custom <style> tag isn't, meaning it makes matters worse. The weird part: removing thecomposes
still removes the duplicate <style> tag, almost as if our custom .css file was being taken into consideration after all.--
Also, I tried to change the name of our own .css file so that it does not contain
.module.css
, but that did not help either.Debug Report
Please complete the following device information:
Please let us know what packages this bug is in regards to:
venia-concept
venia-ui
pwa-buildpack
peregrine
pwa-devdocs
upward-js
upward-spec
create-pwa
The text was updated successfully, but these errors were encountered: