nextui-org / tailwind-variants

🦄 Tailwindcss first-class variant API
https://tailwind-variants.org
MIT License
2.42k stars 70 forks source link

fix: Support false-only variant with fallback behaviour #159

Closed lrholmes closed 9 months ago

lrholmes commented 9 months ago

Description

After upgrading to the latest version of tailwind-variants, we noticed a small UI regression where a component which specified only a false variant was continually using that, despite true being specifically passed in.

It looks like this occurs because of the logic to always fall back to the false variant if the initial value isn't found:

https://github.com/nextui-org/tailwind-variants/blob/a26d801f13f97af726a0c206ae413cd5543ea7ff/src/index.js#L220

This PR addresses that by changing where the fallback happens. I've also added a couple of tests which cover the case that currently fails.

It's an odd case so hopefully this won't be impacting many other users! In our case, we actually realised that this API choice wasn't ideal and ended up implementing an alternative workaround. Still, the behaviour was very confusing to us for a moment and the fix seems quite simple, so decided to create a PR with the change.

Additional context


What is the purpose of this pull request?

Before submitting the PR, please make sure you do the following