itsjavi / bootstrap-colorpicker

Bootstrap Colorpicker is a modular color picker plugin for Bootstrap.
https://itsjavi.com/bootstrap-colorpicker/
MIT License
1.38k stars 367 forks source link

Disable hex input auto completing #323

Closed cindi123 closed 3 years ago

cindi123 commented 3 years ago

Description

If you type characters directly into the hex input field, it will autocomplete. For example if I type 123 it will autocomplete the field by setting the value to 112233. When you try and delete some characters to change the entry it just continues to autocomplete them. Do not run the setValue() function unless the field loses focus OR there are at least 6 characters in the field. This is driving users crazy. I think you fixed this in your previous version here: https://github.com/zefoy/ngx-color-picker/issues/84. Version 3.2 doesn't have the same fix.

Context

Live Example

You can see this in action on the example page for the plugin - try clearing out the hex value in the "Add complementary color swatches" example and start typing any number or letter and see what it does: https://itsjavi.com/bootstrap-colorpicker/tutorial-p02_Advanced_Examples.html

heliobentes commented 3 years ago

Same issue here

erehulka commented 3 years ago

Have you tried

...
$('#colorpicker').colorpicker({
  autoInputFallback: false
});
...

To be fair it still doesn't work for me, but you can try this setting, maybe it will somehow work for you..

iameddz commented 3 years ago

I've fixed this Issue for the hex-format in the update-function (Line 4653):

var originalColor = this.colorpicker.color._original.color;
if (originalColor.length < 7 && originalColor.startsWith('#')) {
  return;
}
itsjavi commented 3 years ago

That's how the color parsing library works (unfortunately). I think there is a PR from @erehulka that will solve this with an option. thanks for taking care of that in #325