Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 of 6 tasks
yashcr07 opened this issue Aug 26, 2024 · 5 comments
Open
1 of 6 tasks
Assignees
Labels
Bug Something isn't working

Comments

@yashcr07
Copy link

yashcr07 commented Aug 26, 2024

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?

  • Yes I use 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

  • macOS
  • Windows
  • Linux
  • iOS/iPadOS
  • Android

Additional Information

Screenshot 2024-08-27 at 1 10 29 AM

@yashcr07 yashcr07 added the Bug Something isn't working label Aug 26, 2024
@csandman
Copy link
Owner

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
Copy link
Author

yashcr07 commented Aug 28, 2024

@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
Copy link
Owner

csandman commented Sep 5, 2024

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?

@csandman
Copy link
Owner

I also realized there was an issue related to this made a while ago: #223

For some reason I never looked into the actual impact of the change, or think to implement it here. Ah well. I'm still planning to look into it, I've just been more preoccupied with upgrading for Chakra V3.

@yashcr07
Copy link
Author

@csandman no worries, my use case is not specific, I can do the same styling using the chakraStyles prop. I wanted to make it work only using css classes and thus I found out it currently doesn't support.

I'm not sure if you saw the updated sandbox, I've implemented a workaround and it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants
@yashcr07 @csandman and others