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

Opacity slider not reset when entering a hex-color in input box #237

Open
av01d opened this issue Nov 28, 2017 · 1 comment
Open

Opacity slider not reset when entering a hex-color in input box #237

av01d opened this issue Nov 28, 2017 · 1 comment
Labels

Comments

@av01d
Copy link

av01d commented Nov 28, 2017

Reproduce:
Go to https://labs.abeautifulsite.net/jquery-minicolors/ and check the second RGB(A) example.
Now enter '#ff0000' in the input box.
The newly entered color is selected in the color grid, but the opacity slider stays where it was, while it should be moved all the way to the top (a hex color is fully opaque).
The fix is simple. In jquery.minicolors.js, I added this single line of code, line 586:

    // Determine hex/HSB values
    if(isRgb(input.val())) {
      // If input value is a rgb(a) string, convert it to hex color and update opacity
      hex = rgbString2hex(input.val());
      alpha = keepWithin(parseFloat(getAlpha(input.val())).toFixed(2), 0, 1);
      if(alpha) {
        input.attr('data-opacity', alpha);
      }
    } else {
      hex = convertCase(parseHex(input.val(), true), settings.letterCase);
      input.attr('data-opacity', ''); // FIX
    }
@claviska
Copy link
Owner

I think this is more of a behavioral question than a bug.

If you compare entering a hex value via keyboard to entering via slider, the current behavior is consistent. For example, you don't expect opacity to change when sliding, so why should it change when typing?

I'm not sure if it should reset in this case. Open to other opinions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants