Closed Bug 965181 Opened 8 years ago Closed 6 years ago

Changing a color with the color picker tooltip does not respect the color unit

Categories

(DevTools :: Inspector, defect)

defect
Not set
normal

Tracking

(firefox44 fixed)

RESOLVED FIXED
Firefox 44
Tracking Status
firefox44 --- fixed

People

(Reporter: pbro, Assigned: tromey)

References

Details

Attachments

(1 file, 1 obsolete file)

- Open the inspector on any page,
- find a color property that has a color-swatch next to the color value,
- click on the swatch and edit the color.

==> Expected: The new, edited, color should always be in the same format as the color originally was.
==> Actual: The new color is in rgba format, or with the patch in bug 940507 applied, the new color respects the default color unit set in the devtools options.
It's possible to add alpha to a color, so we can't always comply.
Perhaps we need a set of alternate formats for when alpha is added.

RGB->RGBA, etc is obvious
Hex->RGBA ?

We also need to think about the alpha-removed case, which could be trickier?
I think it makes more sense to respect the user's unit setting since the user is comfortable with it. Maybe the color picker could show some radio buttons to choose the unit, and fallback to another one if not available.
Some more thought. There are 6 'color spaces' (I think):

* named colors (and I'm including system colors and 'transparent', etc here)
* hex
* rgb, rgba
* hsl, hsla

As noted, there's not a 1:1 mapping between these spaces (and that's a principle of color spaces in general for deeper reasons).

I think a good citizen programmer will respect the code style around what they're editing, and similarly we should avoid changing color units where possible, otherwise I agree with Tim' thoughts that the users selected settings are a strong preference.

So here's my proposal:

* When editing a named color, convert it to the user's setting. (Maybe a future bug could consider finding closest named color matches, but that's not important now)
* When editing rgba or hsla, keep using those units
* When editing hex, rgb or hsl, use those units unless the user adds transparency and then use the users setting (if that supports transparency or rgba if not)

We create a new bug to add radio buttons that show the color (updating dynamically) in the various units, allowing the user to pick a different format.
+1 for me!
I like what Joe Walker is proposing. The way to go is using the unit that the user selects by default - unless there's a reason not to be able to do so ( transparency ).

So for instance, if in my settings I have that I want "Hex", and I change the color by adding transparency, it should give me a rgba. If I want to go back to hex - I can just remove the transparency and it should give me a hex again.


Hope this can be implemented soon - this is a major headache for me.

Cheers.
I got bitten by this a couple of times now - current Beta (40) and Aurora (41) - and just found this bug. It is not the same as 940507 even though the wording is pretty similar, right?
My "Default color unit" is set to Hex, but the color unit I get when pasting a color from the color picker is always RGB. My first assumption was the "Default color unit" setting is generally broken and I was about to file bug against that.

(In reply to Joe Walker [:jwalker] (overloaded - needinfo me or ping on irc) from comment #3)
> We create a new bug to add radio buttons that show the color (updating
> dynamically) in the various units, allowing the user to pick a different
> format.

Sounds like a good idea indeed, has that task been created yet?
Flags: needinfo?(jwalker)
Forwarding needinfo to Patrick. I know we've been thinking about this a bit recently.
Flags: needinfo?(jwalker) → needinfo?(pbrosset)
I tried this out with the as-authored series (bug 984880).

There, when the default color is set to "Authored", thinks pretty much
work as in comment #3; since "the user's setting" means "the same format
as appeared in the CSS text".

It's also worth noting that you can cycle between the different color
formats by shift-clicking on the color swatch.  Maybe this satisfies the
radio button idea.

Even with as-authored there is still the bug where selecting hex as the
default style doesn't result in the color picker editing in hex values.
I have a simple patch for this based on the as-authored series.
Assignee: nobody → ttromey
Status: NEW → ASSIGNED
Depends on: 984880
Attachment #8666879 - Flags: review?(mratcliffe)
Attachment #8666879 - Flags: review?(mratcliffe) → review+
Minor tweak (changing case of a hex color) to make the test pass in
isolation.  This will be undone in the next patch.
Attachment #8666879 - Attachment is obsolete: true
Attachment #8670935 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/cd09b70dd073
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 44
Flags: needinfo?(pbrosset)
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.