Skip to content

Keep the hue slider's hue for white, gray and black - #11

Open
RrrrobertB1992 wants to merge 2 commits into
paxx12:mainfrom
RrrrobertB1992:color-picker-hue-from-white
Open

RrrrobertB1992 wants to merge 2 commits into
paxx12:mainfrom
RrrrobertB1992:color-picker-hue-from-white

Conversation

@RrrrobertB1992

Copy link
Copy Markdown

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

setFromHex now 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:

  • Editing the hex value by hand updates both the color square and the slider position.
  • Moving the slider doesn't change the selected color, but redraws the square with the matching palette.
  • After picking a color in the square, moving the slider shifts the palette and updates the hex value correctly.
  • All 5 color pickers behave the same way.

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

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

No deployments
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.

1 participant