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

Cache hue value locally on ColorPicker #7291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

waldeck-dev
Copy link

Fixes #4720

My team and I came across Issue #4720 recently. I'll add a few more observations to describe this bug:

  • The problem occurs when you drag the handle to the black color, as described by @cyhnkckali on Issue, which corresponds to the bottom edge of the selector. The left edge also causes the same behavior and corresponds to the different shades of gray, up to white.
  • The problem occurs when using the prop format="hex" (default) and format="rgb". The problem is not reproduced when using format="hsl".

This last point helps us understand where the problem comes from. Colors from white to black, and all shades of gray in between, are hue-insensitive. The hue selector can be set to any position, the color will always be the same.

However, the use of the prop format="hex"/format="rgb" coupled with the circular nature of the v-model means that the value we emitted ($emit()) and the one re-injected through the v-model loses the information about hue. For example, for black :

  • hex = #00000: no hue information
  • rgb = rgb(0, 0, 0) : no hue information
  • hsl = hls(123°, 0%, 0%): hue information is present, although useless when describing black

My proposed solution simply caches the hue value inside component so that it will always be set locally even if the information gets lost once emitted.

Copy link

vercel bot commented Feb 20, 2025

Deployment failed with the following error:

Creating the Deployment Timed Out.

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

Successfully merging this pull request may close these issues.

Color Picker
1 participant