adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.72k stars 1.09k forks source link

ColorSwatch does not apply UNSAFE_className #6583

Closed CHE1RON closed 3 months ago

CHE1RON commented 3 months ago

Provide a general summary of the issue here

Using ColorSwatch, I want to give it a border, but it is not applied, no matter what I do ๐Ÿ˜…

๐Ÿค” Expected Behavior?

Given this code:

    <ColorSwatchPicker>
      {colors.map((color) => (
        <ColorSwatch
          key={color}
          color={color}
          UNSAFE_className="border border-black/10" // < does not work
        />
      ))}
    </ColorSwatchPicker>

๐Ÿ˜ฏ Current Behavior

no border showing

๐Ÿ’ Possible Solution

I checked the component source code, but to me it seems that className is applied after using useStyleProps so maybe it gets overwritten?

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

Paste code above with list of some color codes and try to apply UNSAFE_className

Version

3.35.1

What browsers are you seeing the problem on?

Firefox, Chrome

If other, please specify.

No response

What operating system are you using?

macOS

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

snowystinger commented 3 months ago

Looks like we're accidentally overwriting it https://github.com/adobe/react-spectrum/blob/2fd87d9f1d894e6b00a595cce73c6e8828029132/packages/%40react-spectrum/color/src/ColorSwatch.tsx#L64

want to contribute a fix?

CHE1RON commented 3 months ago

let me have a look ๐Ÿ˜‰