Skip to content

classes() function does not resolve Tailwind class conflicts when element has existing classes #1222

@mamadshni

Description

@mamadshni

Please provide the environment you discovered this bug in.

Node: v24.6.0
Angular: v20.0.6

Which area/package is the issue in?

accordion

Description

@spartan-ng/helm/utils

Other information

Expected behavior: When calling classes(() => ['bg-red-500', 'text-white']) on an element with existing class bg-blue-500 p-2, the result should be p-2 text-white bg-red-500 (new bg-* replaces old).

The existing test in the codebase documents this bug - the comment says one thing but the expectation tests for the opposite:

it('should handle class merging and deduplication', async () => {
  ....
  // twMerge should resolve bg conflict, keeping the last one (bg-red-500)
  expect(element.className).toBe('text-white bg-blue-500 p-2'); // ← keeps bg-blue-500, not bg-red-500
  ....
}

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions