fix: prevent arbitrary font-family and font-weight from merging#635
Merged
dcastil merged 12 commits intodcastil:mainfrom Jan 31, 2026
Merged
fix: prevent arbitrary font-family and font-weight from merging#635dcastil merged 12 commits intodcastil:mainfrom
dcastil merged 12 commits intodcastil:mainfrom
Conversation
dcastil
approved these changes
Jan 31, 2026
Owner
dcastil
left a comment
There was a problem hiding this comment.
Hey @roneymoon! 👋
I expected a fix to be much more involved, awesome that you found a much simpler solution! Thanks for fixing the issue!
I fixed some additional minor nuances and added some tests and docs for the changes.
|
This was addressed in release v3.4.1. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this change do?
This PR fixes an issue where arbitrary
font-familyandfont-weightutilities were incorrectly merged bytailwind-merge, causing one of them to be dropped when both were present.The problem occurred because the
font-weightclass group was using an overly broad arbitrary validator, which also matchedfont-familyvalues (e.g.family-name:). As a result, both utilities were classified into the same group and one would override the other.This change makes the
font-weightmatching more precise so that each utility is correctly classified and both can safely coexist.What was the issue?
Given the following input:
Before
'font-(--custom-weight)'After
'font-(family-name:--custom-family) font-(--custom-weight)'The same incorrect behavior happened regardless of class order.
How is this fixed?
Introduced weight-specific arbitrary validators that only match:
unlabeled variables intended for font weight (e.g. (--custom-weight))
explicitly labeled weight values (e.g. (weight:...), (number:...))
Replaced the generic isArbitraryVariable usage in the font-weight class group with these more specific validators
Left font-family logic unchanged so it continues to correctly handle family-name: and other family-related arbitrary values
This avoids the over-matching that caused both utilities to be treated as font-weight.
Why this approach?
Keeps the fix minimal and localized
Avoids changing validator execution order or introducing priorities
Does not modify configuration or public APIs
Preserves existing behavior while fixing the incorrect merge
Thanks for taking a look!
Closes #588