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

Transparency still possible with disableAlpha=true #268

Closed
aGautrain opened this issue Feb 13, 2020 · 4 comments
Closed

Transparency still possible with disableAlpha=true #268

aGautrain opened this issue Feb 13, 2020 · 4 comments
Labels

Comments

@aGautrain
Copy link

aGautrain commented Feb 13, 2020

Hello,

Disabling alpha removes slider as expected (I'm using color-sketch implementation),

But if user types an HEX with a length of 4 such as 1230, it will be converted into a color of #112233 (which is normal behavior), but a transparency set to 0%.
It typically happens when user deletes some chars of a 6-length HEX, coming down to a HEX of 4 and so, transparency.

I think it's a way to bypass the behavior we expect when setting disableAlpha to TRUE.
What do you think ?

Thanks for your time

--
I can do a PR if needed, I've looked into code and it seems to be related with isValidHex(hex: string) / handleChange not taking into account disableAlpha attribute.

@vitokhangnguyen
Copy link

I am not sure I understand the title correctly but isn't that when disableAlpha=false, it is the default? Which means Alpha should be available.

It should be gone if disableAlpha=true.

@aGautrain
Copy link
Author

I've inverted false and true while explaining but the problem remains the same

Here is a screenshot (and it's easily reproducible)
You can see there is no transparency slider (because disableAlpha is set to TRUE)
But it's still possible to create a transparent color (with a four-length hex code, last char matches transparency while it should not, as alpha is disabled)

Screenshot 2020-02-25 at 11 30 32

I've come across a custom solution myself where I remove that transparency when a color is emitted, but I think it should be included in ngx-color code directly.

@aGautrain aGautrain changed the title Transparency still possible with disableAlpha=false Transparency still possible with disableAlpha=true Feb 25, 2020
@vitokhangnguyen
Copy link

Nice. I think you should make a PR about that. I am just going through this when I tried to use this component for my Angular app.

@scttcper
Copy link
Owner

🎉 This issue has been resolved in version 5.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

3 participants