Skip to content

Conversation

ali-idrizi
Copy link

@ali-idrizi ali-idrizi commented Aug 14, 2025

Description

When having multiple slots, and not specifying the slot key in compoundVariants, like:

tv({
  base: "",
  slots: {
    title: "",
  },
  compoundVariants: [{
    class: "truncate", // not explicitly passing to a specific slot
  }]
})

Conveniently, the class truncate is added to base. However, if class is an array like:

tv({
  base: "",
  slots: {
    title: "",
  },
  compoundVariants: [{
    class: ["truncate"],
  }]
})

While one would expect the same behavior, the truncate class is not passed anywhere, even though it's type-safe. The reason is that the condition that adds the class to the base slot, only checks for typeof class === "string".

This PR adds an additional check for Array.isArray. I have modified one of the tests, so it fails without the added check. Let me know if the PR can be improved in any way.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

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

  • Read the Contributing Guidelines.
  • Follow the Style Guide.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant