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 !important added when rules have multiple selectors #9677

Closed
cjpearson opened this issue Oct 28, 2022 · 0 comments
Closed

Unexpected !important added when rules have multiple selectors #9677

cjpearson opened this issue Oct 28, 2022 · 0 comments

Comments

@cjpearson
Copy link
Contributor

What version of Tailwind CSS are you using?

v3.2.1

What build tool (or framework if it abstracts the build tool) are you using?

webpack 5.74.0

What version of Node.js are you using?

v16.18.0

What browser are you using?

Firefox

What operating system are you using?

macOS

Reproduction URL

https://play.tailwindcss.com/VMLRCIqg77?file=config

Describe your issue

When adding rules with multiple selectors in a plugin, the generated CSS for the !important modifier can cause issues. The !important rule includes all selectors from the original rule, even those which don't include the modified class.

For example, when adding a utility or component with these rules

'.btn': {
     '&.disabled, &:disabled': {
         color: 'gray',
     }
}

the following CSS is generated

.btn.disabled, .btn:disabled {
  color: gray;
}

.btn.\!disabled, .btn:disabled {
  color: gray !important;
}

but I think the following makes more sense

.btn.disabled, .btn:disabled {
  color: gray;
}

.btn.\!disabled {
  color: gray !important;
}

The workaround in this case is straightforward, just splitting the rule in two.

'.btn': {
     '&.disabled': {
         color: 'gray',
     },
    '&:disabled': {
         color: 'gray',
     }
}
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

1 participant