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

Insert @defaults at start of stylesheet #14427

Merged
merged 6 commits into from
Sep 17, 2024

Conversation

adamwathan
Copy link
Member

Prior to this PR, we'd put all of the @defaults (the CSS variables and stuff) after the base rules. This creates an issue when using optimizeUniversalDefaults with CSS that looks like this:

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  input {
    @apply shadow;
  }
}

…because the default shadow stuff ends up after the base input rules, so the generated styles are like this:

input {
  --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color),
    0 1px 2px -1px var(--tw-shadow-color);
  box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
    var(--tw-shadow);
}

input {
  --tw-ring-offset-shadow: 0 0 #0000;
  --tw-ring-shadow: 0 0 #0000;
  --tw-shadow: 0 0 #0000;
  --tw-shadow-colored: 0 0 #0000;
}

This means all of the actual shadow values for the input are reset and the shadow doesn't work.

Fixes #14426.

Lots of failing tests right because this changes a ton of stuff, albeit in a totally inconsequential way. @thecrypticace if you could update these for me this week that would be a huge help, just banging this fix out quick while the kids are napping 😴

@@ -118,22 +118,20 @@ export default function resolveDefaultsAtRules({ tailwindConfig }) {
}
}

if (flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {
Copy link
Member Author

@adamwathan adamwathan Sep 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional was unnecessary, if you look up at line 94 you can see this code is already inside a block with the exact same conditional.

if (flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {

CHANGELOG.md Outdated Show resolved Hide resolved
@adamwathan adamwathan merged commit fe48ca8 into main Sep 17, 2024
13 checks passed
@adamwathan adamwathan deleted the fix/apply-base-optimize-universals branch September 17, 2024 13:09
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 this pull request may close these issues.

2 participants