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

ColorPicker goes transparant when no value is entered into ColorField #6363

Open
xiavn opened this issue May 10, 2024 · 2 comments · May be fixed by #6364
Open

ColorPicker goes transparant when no value is entered into ColorField #6363

xiavn opened this issue May 10, 2024 · 2 comments · May be fixed by #6364
Labels
bug Something isn't working

Comments

@xiavn
Copy link

xiavn commented May 10, 2024

Provide a general summary of the issue here

In your example documentation for building a Color Picker using a Color Area, Field, Swatch and Slider, if you delete the content in the Color Field so the the field is left blank and then blur the input the value gets automatically changed to "#000000", and the swatch changes to transparant in colour.

If you then try to move the slider or area selection around, the hex value is updated in the field component, but the swatch remains showing a transparant colour.

The only way to stop the swatch from being transparant is to type a value manually into the ColorField, which then causes it to update correctly.

🤔 Expected Behavior?

When the field value is set automatically to #000000 I would expect the swatch to be black not transparant, I would also expect the swatch to update correctly when the sliders are moved after such an action.

😯 Current Behavior

Color Picker incorrectly sets colour on swatch to transparant and then doesn't update correctly.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

Go to https://react-spectrum.adobe.com/react-aria/ColorPicker.html and open the first example colour picker.

Delete the content in the colour field input and then try to change colour using the slider or colour area.

Version

1.2.0 of aria-components

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

MacOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@reidbarber
Copy link
Member

Looks like when parsing the value, we're replacing #0000 (the default value) with #00000000, which sets the alpha channel to 0:

const values = (value.length < 6 ? value.replace(/[^#]/gi, '$&$&') : value).slice(1).split('');

This doesn't make much sense since #000000 will use a full alpha channel in the same function. We should update this function, or set the default value to #000000 instead of #0000.

@reidbarber reidbarber added the bug Something isn't working label May 10, 2024
@reidbarber
Copy link
Member

After a second look, I think the parsing #0000 to #00000000 should be expected, and we should update the default value to have a full alpha channel.

@reidbarber reidbarber linked a pull request May 10, 2024 that will close this issue
5 tasks
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

Successfully merging a pull request may close this issue.

2 participants