-
Notifications
You must be signed in to change notification settings - Fork 414
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
[React] CSS specificity issue: extend imported component #1378
Comments
@Anber nice release yesterday 👌 I like the way this project is going. The only workaround I could find is to find those style overrides manually and artificially increase specificity ( Thanks |
Hi @PierreGUI Unfortunately, I haven't had enough time for the last two months. And I will be completely offline for the next two and a half weeks. I will take a look as soon as I return. |
Hey @Anber , friendly reminder of this troubling issue. Any chance you'll have a look at it soonish? |
Hi @PierreGUI Sorry for such a late response. It appeared that |
Environment
Linaria version: 5.0.3
Bundler: Webpack 5
Description
When extending a component with
styled
function (const B = styled(A)``;
) I expect the resulting component's CSS to have higher specificity.When the components are declared in the same file, Linaria seems to append the parent's classname to the child's (
.B.A
-> increased specificity) ✅When the component to extend from is imported, Linaria doesn't append its classname. The new component's specificity is the same as its parent component ❌
This result is mismatching style when a child component inherits from a complex parent component, defined in another file:
In this example the classname for
Red
is.Red_rhnsy8v
which has lower specificity than.Blue_b7lcn1q.Base_b15uhwgc
, therefore the text isn't red but blue.It should be
.Red_rhnsy8v.Blue_b7lcn1q.Base_b15uhwgc
in order to override its parent's style correctly.See the reproduction demo for source code.
Reproducible Demo
https://stackblitz.com/edit/linaria-bug-kahsvz?file=src%2FTitle.tsx
The text was updated successfully, but these errors were encountered: