Cache hue value locally on ColorPicker #7291
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4720
My team and I came across Issue #4720 recently. I'll add a few more observations to describe this bug:
format="hex"
(default) andformat="rgb"
. The problem is not reproduced when usingformat="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 thev-model
means that the value we emitted ($emit()
) and the one re-injected through thev-model
loses the information about hue. For example, for black :hex
=#00000
: no hue informationrgb
=rgb(0, 0, 0)
: no hue informationhsl
=hls(123°, 0%, 0%)
: hue information is present, although useless when describing blackMy 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.