chakra-react-select icon indicating copy to clipboard operation
chakra-react-select copied to clipboard

[BUG] Version 4.7.6 breaks colors for selected item

Open rogama25 opened this issue 1 year ago • 2 comments

Description

Version 4.7.6 overrides your set colors for the selected elements through aria-selected css selector while I think it shouldn't. Reverting to 4.7.5 works as expected, according to #99

4.7.5: image

4.7.6: image

chakra-react-select Version

4.7.6

Link to Reproduction

https://codesandbox.io/p/sandbox/test-dropdown-ftll7r?file=%2Fpackage.json

TypeScript?

  • [X] Yes I use TypeScript

Steps to reproduce

  1. Create a project with a <Select> using chakra-react-select 4.7.6
  2. Set up styles changing chakraStyles for the optionMenu setting colors, as suggested in #99
  3. Colors do not appear as expected
  4. Change package.json to use version 4.7.5
  5. Reinstall npm packages and reload
  6. Working as expected

Operating System

  • [ ] macOS
  • [ ] Windows
  • [X] Linux
  • [ ] iOS/iPadOS
  • [ ] Android

Additional Information

This might be related to some cleanup that was done to aria props and styles (maybe this commit 8ddad8211dcebf8bca7f356b3c830c6177287e49)

rogama25 avatar Dec 26 '23 17:12 rogama25

Sorry for the late response!

Yes I see your point, the styles passed in chakraStyles should generally override the built-in styles, meaning I should switch back from using the pseudo selectors as they increase specificity. I've been very busy recently but I'll get to this soon.

csandman avatar Jan 10 '24 02:01 csandman

So I'm working on a new version that will solve this, but I'm also integrating the new accessibility changes react-select implemented recently. But in both cases (now and after the new version), you can implement these styles by using the _selected pseudo selector:

      chakraStyles={{
        option: (provided) => ({
          ...provided,
          _selected: {
            backgroundColor: "pink",
            color: "orange",
          },
        }),
      }}

I plan to also reduce the specificity of the built in styles so this isn't an issue, but this fix should work now.

csandman avatar Jan 17 '24 00:01 csandman