sadpandajoe commented on code in PR #42910:
URL: https://github.com/apache/superset/pull/42910#discussion_r4417848680


##########
superset-frontend/src/explore/components/controls/ColorPickerControl.tsx:
##########
@@ -49,13 +63,20 @@ export interface ColorPickerControlProps {
   ariaLabel?: string;
   resolveThemeTokens?: boolean;
   outputFormat?: ColorOutputFormat;
+  disabled?: boolean;
 }
 
 const normalizeColorToHex = (color: string): string => {
   if (!color) return '';
 
   if (color.startsWith('#')) {
-    return color.toLowerCase();
+    const lower = color.toLowerCase();
+    // Expand 3/4-digit shorthand so it compares equal to the six/eight-digit
+    // hex the picker emits.
+    if (/^#[0-9a-f]{3,4}$/.test(lower)) {

Review Comment:
   A theme token such as `colorSuccess: '#0f0'` now expands, but an opaque 
four-digit value like `colorError: '#f00f'` expands to `#ff0000ff`, while 
`handleChange` compares against `rgbaToHex(rgb)`, which drops the alpha byte 
when alpha is 1 and yields `#ff0000`. Picking the Red chip then misses the 
special-key match and stores the rgb object instead of `'Red'`. Should the 
opaque-alpha case be normalized here (drop a trailing `ff`) so it compares 
equal?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to