spectrum icon indicating copy to clipboard operation
spectrum copied to clipboard

Return rgba to original input when alpha channel is used

Open mycosd opened this issue 10 years ago • 4 comments

When you set preferredFormat eg. to "hex" then the colorpicker result in the original input field will always be in hex, even if showAlpha=true and the user selected an alpha less than 1. The colorpicker should return rgba instead (like the preview input field does).

Here is the difference: current master: http://jsfiddle.net/7sun5j3c/ pull request: http://jsfiddle.net/7sun5j3c/1/ You'll have to select a color with alpha < 1

mycosd avatar Oct 19 '15 17:10 mycosd

+1

vitornogueira avatar Nov 05 '15 23:11 vitornogueira

I think this makes sense, sorry for the delay. Will leave comments inline

bgrins avatar Dec 16 '15 02:12 bgrins

Would you be able to add a new test for this? They can be run by loading test/index.html in a browser. We have an existing test for preferredFormat and tooltips: https://github.com/bgrins/spectrum/blob/master/test/tests.js#L501; so it could go near there but be a lot simpler.

$('<input />').spectrum({
    preferredFormat: "hex",
}).spectrum("set", "rgba(255,0,0,.2)").val() // make sure this is rgba(255,0,0,.2)

$('<input />').spectrum({
    preferredFormat: "hex",
}).spectrum("set", "rgba(255,0,0,1)").val() // make sure this is "#ff0000"

$('<input />').spectrum({
    preferredFormat: "name",
}).spectrum("set", "rgba(0,0,0,0)").val() // make sure this is transparent

bgrins avatar Dec 16 '15 02:12 bgrins

Any updates when release with this changes can be published?

vedmant avatar Apr 14 '18 05:04 vedmant