bgrins / spectrum

The No Hassle JavaScript Colorpicker
https://bgrins.github.io/spectrum/
MIT License
2.32k stars 589 forks source link

transparent should not fall back to black #84

Open karolk opened 11 years ago

karolk commented 11 years ago

When you type transparent in the input field and press enter it changes to #000000. This is a bit misleading for the user. Ideally it would not change the position of the dragger and kept the name as 'transparent'.

http://jsbin.com/iroqoq/1/edit

bgrins commented 11 years ago

I see that. Part of the issue is the display is driven by a preferredFormat, but I could see just having a special case for transparent where it doesn't use that format (and possibly also doesn't move the dragger). What should happen at that point if they start dragging around afterwards though? Typically, if showAlpha is false it doesn't allow any alpha so I don't have to deal with this case (try typing in 'rgba 100 100 100 .5'), but I guess that 'transparent' is allowed for whatever reason.

I suppose you could just manually handle it, as in something like this: https://github.com/bgrins/spectrum/issues/83

Ahjira commented 10 years ago

I can see a case for this either way. It depends on what the user is trying to do. Spectrum does not have a "clear" option so if I set a color to entirely transparent, I'm usually trying to clear the color and in that case, I'd prefer it did reset to black because that intuitively tells me "no color". I would consider this in light of the fact you may eventually have a clear option. If so, then leaving the color in tact when alpha is 0 provides a clear second use case. Right now it doesn't.