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

Unexpected behaviour when extending components #547

Open
dashzt opened this issue May 18, 2023 · 1 comment
Open

Unexpected behaviour when extending components #547

dashzt opened this issue May 18, 2023 · 1 comment

Comments

@dashzt
Copy link

dashzt commented May 18, 2023

I've created a demo repo to this bug, so it's easier to understand it https://github.com/dashzt/goober-extending-components-bug

Gist of the problem:
We are using preact (10.11.3) and goober (2.1.13) on our project.
We have 2 level inheritance of extended components
Example from demo app:

export const Red50 = styled('button')`
  width: 50px;
  height: 50px;
  background: red;
  color: white;
`

export const Blue50 = styled(Red50)`
  background: blue;
`

export const Blue100 = styled(Blue50)`
  width: 100px;
  height: 100px;
`

Then actuall styles applied to the last component (Blue100 in this example) become dependant on the order in which those components are mounted to preact

I've found the order, which I also used in a demo app:

<Red50>
  Red 50
</Red50>
<Blue100>
  Blue 100
</Blue100>
<Blue50>
  Blue 50
</Blue50>

In this case Blue100 and Blue50 have their styles broken
image

If I take a closer look on Blue100 and Blue50 styles, I see that background: blue class is applied
image

Which I can see is overriden but background: red, because of the order class selectors are put into
image

I believe all other combinations of mount order work well

@dashzt dashzt changed the title Unexpected behaviout when extending components Unexpected behaviour when extending components May 18, 2023
@buchansm
Copy link

buchansm commented Sep 1, 2023

@cristianbote, any updates on this? I'm also running into this problem. This is not a trivial bug. If users can't overwrite css properties, then goober is not a valid css-in-js solution.

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

2 participants