csandman / chakra-react-select

A Chakra UI themed wrapper for the popular library React Select
https://www.npmjs.com/package/chakra-react-select
MIT License
772 stars 33 forks source link

[BUG] classNames prop from react-select doesn't work, using in react-select directly works #330

Open yashcr07 opened 2 weeks ago

yashcr07 commented 2 weeks ago

Description

When passing the classNames prop from react-select in chakra-react-select it doesn't apply the class to the respective component. Eg.

classNames={{
  control: (state) => cx("select-control", state.menuIsOpen ? "menu-open" : null),
}}

I see the props are spread here, which should pass it to react-select and this should probably work

chakra-react-select Version

4.9.1

Link to Reproduction

https://codesandbox.io/p/sandbox/chakra-react-select-classnameprefix-demo-forked-cyym58?file=%2Fexample.js%3A15%2C33

TypeScript?

Steps to reproduce

I've used the same configuration for both the dropdowns, you'll see the react-select dropdown applies the class but not chakra-react-select

Operating System

Additional Information

Screenshot 2024-08-27 at 1 10 29 AM

csandman commented 2 weeks ago

Interesting, I've never actually used this prop from react-select, so I'm not sure why those aren't getting forwarded. I'll take a look at what's going on and let you know.

yashcr07 commented 2 weeks ago

@csandman I found the issue, it will only work out of the box with components which are not part of this lib's chakraComponents. I've updated the sandbox with a custom Control component and it works, so I'm not sure if this is a bug and how you'd want to handle this, but surely would be helpful to include it in the docs.

csandman commented 1 week ago

I've recently taken a look comparing the custom internal components of react-select and the ones I made for charka-react-select, and realized mine are a bit out of date haha. That classNames prop is actually newer than my components, so none of mine actually have support for it yet. This was the issue/PR where it was originally introduced for reference:

So in order to add support for the classNames prop, I'm going to have to do a larger scale change across the custom components in this package, which will probably take a bit, so I'll have to find some time I can get to it.

For more info, can you fill me in on the specific use case you have for this? Are you trying to pair this with tailwind or something like the original feature was designed for?