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

undefined doesn't remove the class #609

Closed
babakfp opened this issue Sep 17, 2022 · 3 comments · Fixed by tailwindlabs/tailwindcss#9385
Closed

undefined doesn't remove the class #609

babakfp opened this issue Sep 17, 2022 · 3 comments · Fixed by tailwindlabs/tailwindcss#9385

Comments

@babakfp
Copy link

babakfp commented Sep 17, 2022

What version of Tailwind CSS are you using?

v3.1.8

Reproduction URL

https://play.tailwindcss.com/3kRy1GbH6z

Describe your issue

For example, I want to remove black: #000 from the colors object, So, I do this:

module.exports = {
  theme: {
    extend: {
      colors: {
        black: undefined,
      },
    },
  },
}

The issue is that the color black will still be suggested.

Maybe it's something related to tailwind itself because the key black still does exist in the colors object. Maybe tailwind can remove the item if the value is equal to undefined.

Thanks

@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

Going to leave it open and let @bradlc decide what to do with this. However, one thing you can do is set the value to null instead of undefined which doesn't suggest bg-black anymore.

https://play.tailwindcss.com/eHCuHrnxdL

@bradlc
Copy link
Contributor

bradlc commented Sep 21, 2022

@RobinMalfait, I believe this is a bug in tailwindcss itself, in the getClassList function. I think we need to check for undefined values (and other falsy values?) in this loop? https://github.com/tailwindlabs/tailwindcss/blob/master/src/lib/setupContextUtils.js#L840-L845

@RobinMalfait
Copy link
Member

Ah yep, good catch. I'll fix that!

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