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

Using <Panel5 />, when first loading the picker, the color set as "value" is not reflected in the selector. #47

Closed
LagoonProject opened this issue Oct 8, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@LagoonProject
Copy link

LagoonProject commented Oct 8, 2023

Description

Using <Panel5 />, when first loading the picker, the color set as "value" is not reflected in the selector. The color is indeed selected, but the selector remains on "white". This happens on some colors, not all.

For example, if setting "black", "#785800" or "#0056d6" to "value", the selector stays on those colors when the picker in loaded.

But if setting "#0041a8", "#bd3812" or "#f5ed00" to "value", the right color is set and shows in the preview, but the selector stays on the "white" square. Even though all these colors are available on the grid. Again, the value color is selected, but visually the selector stays on "white".

Steps to reproduce

  1. set <ColorPicker value={'#0041a8'}
  2. load <Panel5 />
  3. The selector remains on "white" but the right color '#0041a8' is displayed in the Preview and is set.

Snack or a link to a repository

No response

Reanimated Color Picker version

2.3.5

React Native version

0.72.4

React Native Reanimated version

3.5.4

React Native Gesture Handler version

2.12.1

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Debug mode

@LagoonProject LagoonProject added the bug Something isn't working label Oct 8, 2023
@alabsi91
Copy link
Owner

alabsi91 commented Oct 9, 2023

Hey, those colors "#0041a8," "#bd3812," or "#f5ed00" you mentioned are not the exact colors in the grid. You can check the grid colors here: Panel5.tsx

@LagoonProject
Copy link
Author

Hey, those colors "#0041a8," "#bd3812," or "#f5ed00" you mentioned are not the exact colors in the grid. You can check the grid colors here: Panel5.tsx

Thanks for your answer. The colors I mentioned are the ones that appear in the preview:

Capture d’écran 2023-10-09 à 10 38 06

For example, if I use the color "#0042A9" in "value" which is in the 'gridColors' array in your link, it will open displaying '#0041a8' instead in the Preview and the selector will be in that square as in the picture.

But if I use '#0041a8' in 'value', the selector will be on the top left "white" square.

Or maybe there's something I misunderstood.

Anyway I'm going to use the colors of the 'gridColors' array and disable the Preview text for now.

Thanks.

@alabsi91
Copy link
Owner

alabsi91 commented Oct 9, 2023

The issue is that the grid is looking for the exact color. The color in the preview is very close but not exact due to color conversion. All colors in the color picker are converted to the HSV (HSB) format, then converted back to the desired format, which in your case is HEX. I might implement a color comparison function with an error tolerance to match the grid colors, but I'm not sure if it's the right thing to do.

@LagoonProject
Copy link
Author

LagoonProject commented Oct 9, 2023

The issue is that the grid is looking for the exact color. The color in the preview is very close but not exact due to color conversion. All colors in the color picker are converted to the HSV (HSB) format, then converted back to the desired format, which in your case is HEX. I might implement a color comparison function with an error tolerance to match the grid colors, but I'm not sure if it's the right thing to do.

Ok I get it. Indeed the color that appears in the 'onComplete' function is not the one displayed in the preview, I didn't noticed it at first.

I have not looked into the code much yet, but maybe there's a way to display the value of the color before conversion directly in the Preview instead ? So at least the color displayed in preview and the color selected have the same value.

Anyway thanks for your answers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants