Skip to content

Commit 6db9533

Browse files
authored
fix: reset postfix modifier position if invalid (#14)
* fix: reset postfix modifier position if invalid * test: add test case for resetting postfix modifier position
1 parent c9aa9e3 commit 6db9533

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

pkg/twmerge/create-tailwind-merge_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,10 @@ func TestTailwindMerge(t *testing.T) {
522522
in: "hover:bg-red-500/90",
523523
out: "hover:bg-red-500/90",
524524
},
525+
{
526+
in: "group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 group-has-[[data-sidebar=menu-action]]/menu-item:pr-6",
527+
out: "group-has-[[data-sidebar=menu-action]]/menu-item:pr-6",
528+
},
525529
}
526530

527531
for _, tc := range tt {

pkg/twmerge/modifier-utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ func MakeSplitModifiers(conf *TwMergeConfig) SplitModifiersFn {
4949
// fix case where there is modifier & maybePostfix which causes maybePostfix to be beyond size of baseClass!
5050
if maybePostfixModPosition != -1 && maybePostfixModPosition > modifierStart {
5151
maybePostfixModPosition -= modifierStart
52+
} else {
53+
maybePostfixModPosition = -1
5254
}
5355

5456
return baseClass, modifiers, hasImportant, maybePostfixModPosition

0 commit comments

Comments
 (0)