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

Responsive state style not working when using _ #288

Closed
ivanbanov opened this issue Jun 29, 2021 · 5 comments · Fixed by #327
Closed

Responsive state style not working when using _ #288

ivanbanov opened this issue Jun 29, 2021 · 5 comments · Fixed by #327
Labels

Comments

@ivanbanov
Copy link
Contributor

When using responsive states such as

<x.button
  bg={{
    _: { _: "error", hover: "success" },
    md: { _: "info", hover: "error" },
    lg: { _: "success", hover: "info" },
  }}
>
  Cameleon button
</x.button>

only the hover declared in the _ will work, if we remove the _ everything works fine

Link to reproduce it https://codesandbox.io/s/fervent-dewdney-dpqku?file=/src/App.js

@strozw
Copy link
Contributor

strozw commented Nov 10, 2021

I have been unable to update to 3.1.x due to a similar issue.

seems to be affected by the following modify.

b69619e#diff-edd87da59beb6f474c429c0a205143f6d0446314ca8dfab56a814823e1a3520cR74

@agriffis
Copy link
Collaborator

agriffis commented Nov 10, 2021

@strozw That's a typing change, it wouldn't change how responsive states work.

The problem in this bug is the order of the emitted rules. This is from browser inspection of @ivanbanov's sandbox:

.css-1exvybm {
 background-color:red;
}

@media (min-width: 768px) {
 .css-1exvybm {
  background-color:blue;
 }
 .css-1exvybm:hover {
  background-color:red;
 }
}

@media (min-width: 1024px) {
 .css-1exvybm {
  background-color:green;
 }
 .css-1exvybm:hover {
  background-color:blue;
 }
}

.css-1exvybm:hover {
 background-color:green;
}

Media queries don't change specificity, so the final hover rule wins. It needs to be emitted prior to the media queries.

@strozw
Copy link
Contributor

strozw commented Nov 11, 2021

@agriffis

I'm sorry to make a misleading comment.
thanks, I have understand the intent of this issue by your replay.

but I'm facing other issues with _ styles using typescript & xstyled 3.1.x.
therefore, I'll create another issue for this issue.

@gregberge
Copy link
Collaborator

@agriffis I think it is a real bug, we have to address it.

@agriffis
Copy link
Collaborator

@gregberge Yes, my comment was describing the bug in xstyled. I agree we need to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants