-
Notifications
You must be signed in to change notification settings - Fork 915
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
Alpha not updating #655
Comments
Same issue for me. HandleChangeComplete returns the object with correct alpha, but the alpha in the SketchPicker keeps going back to 100 after clicking an alpha or entering via keyboard. |
Same problem here. |
This seems to be the issue: #416 I managed to solve the problem by using the rgba value when the alpha isn't 1. const handleColorChange = (color: ColorResult) => {
let colorStr = color.hex
if(color.rgb.a !== 1){
colorStr = `rgba(${color.rgb.r}, ${color.rgb.g}, ${color.rgb.b}, ${color.rgb.a})`
}
// do something with colorStr...
} |
Here is the solution for 8-digit hex code: const decimalToHex = (alpha: number) => alpha === 0 ? '00' : Math.round(255 * alpha).toString(16)
const handleColorChange = (color: ColorResult) => {
const hexCode = `${c.hex}${decimalToHex(c.rgb.a)}`
} |
Ah, yes, unfortunately this does not support having alphas on pre-defined swatches yet. I will track this in the 3.0.0 milestone to make sure it gets fixed in the new release. |
By adding a workaround for casesandberg/react-color#655. Fixes #125
wow, i fixed it by your answer, thanks very much |
when I change the color property, or change it by clicking the palette, the rgb values change, but not alpha.
The text was updated successfully, but these errors were encountered: