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

Duplicated classes in extended components #2330

Closed
ivanbanov opened this issue Mar 8, 2024 · 2 comments · Fixed by #2341
Closed

Duplicated classes in extended components #2330

ivanbanov opened this issue Mar 8, 2024 · 2 comments · Fixed by #2341

Comments

@ivanbanov
Copy link
Contributor

ivanbanov commented Mar 8, 2024

Description

Extending a component seems to be working fine when it's just 1 level, extending an extended component leads to duplicated classes.

Link to Reproduction

https://stackblitz.com/edit/github-lhhzk8-dkevkj?file=src%2Fapp.tsx,panda.config.ts

Steps to reproduce

// bg_blue.light
const Box = styled('div', {
  base: { background: 'blue.light' },
});

// bg_red.light
const ExtendedBox = styled(Box, {
  base: { background: 'red.light' },
});

// bg_blue.light bg_red.light
const ExtendedBox2 = styled(ExtendedBox, {
  base: { background: 'red.light' },
});

resulting in

image

JS Framework

react

Panda CSS Version

0.34.1

@astahmer
Copy link
Collaborator

astahmer commented Mar 8, 2024

hm, I remember this being an issue but I thought I had fixed it here

looking at your stackblitz, it seems fine ?
image

do I need to do anything else ?

@ivanbanov
Copy link
Contributor Author

Sorry the example was not ideal, I updated the link.
The problem relies on extended components that may use an already extracted class, which will give more specificity to that class, and then the element will have the wrong style.

In the link the div with wrong classes should be

// ExtendedBox2
- bg_red.light text_[white] bg_blue.light text_[white]
+ bg_blue.light text_[white]

// ExtendedDiv2
- bg_blue.light text_[white] bg_red.light text_[white]
+ bg_red.light text_[white]
image

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

Successfully merging a pull request may close this issue.

2 participants