Repository navigation
Keep the hue slider's hue for white, gray and black - #11
Open
RrrrobertB1992 wants to merge 2 commits into
Open
RrrrobertB1992 wants to merge 2 commits into
RrrrobertB1992 wants to merge 2 commits into
Conversation
New tags start white, which has no saturation, so moving the hue slider did nothing until a color was first picked in the square (gray and black behaved the same way). Picking a hue now gives a color with no saturation full saturation, and black full brightness, so the hue shows up straight away; grays keep their brightness. Colors that already have a hue are unchanged. Made with help from Claude
Replaces the previous approach: picking a hue no longer changes the selected color. Moving the hue slider redraws the square in the new hue, but the selected color is then written back to the hex box and re-read by setFromHex. White, gray and black have no hue, so re-reading them reset the hue to 0 and the square snapped back to red. That's why a color had to be picked in the square before the slider did anything. setFromHex now leaves the picker alone when it already shows that color, so the square keeps the slider's hue while the selected color (e.g. the default white) stays where it is. Made with help from Claude
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On a new tag (white), moving the hue slider appeared to do nothing until a color had first been picked in the square. The same happened for gray and black.
Cause
Moving the slider does redraw the square in the new hue. But the selected color is then written back to the hex box and read again through
ColorPicker.setFromHex. White, gray and black have no hue, so reading them back reset the hue to 0, and the square snapped back to red straight away.Fix
setFromHexnow leaves the picker's state alone when it already shows that exact color. The square keeps the slider's hue, while the selected color (e.g. the default white) and its marker stay where they are. Typing a different hex value still updates the picker as before.Testing
Tested on an Android phone (Samsung Galaxy S26), using a build that also includes the multi-color PR (#7), so all 5 color pickers were checked:
Also checked in a headless browser by reading the square's pixels. Before this change the square stayed red after moving the slider from white or black; now it shows the slider's hue, the selected color is unchanged, and picking in the square uses that hue.
Made with help from Claude