fix: Support false-only variant with fallback behaviour #159
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
After upgrading to the latest version of
tailwind-variants
, we noticed a small UI regression where a component which specified only afalse
variant was continually using that, despitetrue
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:tailwind-variants/src/index.js
Line 220 in a26d801
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
fixes #123
).