ColorPickerInput: Allow returning empty color value (#52650)

* ColorPickerInput: Allow returning empty color value

* ColorPickerInput: Do not call onChange if the value didn't change
pull/52706/head
Alex Khomenko 3 years ago committed by GitHub
parent f9d8b68543
commit 1e3135b18a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/grafana-ui/src/components/ColorPicker/ColorPickerInput.tsx

@ -29,6 +29,14 @@ export const ColorPickerInput = forwardRef<HTMLInputElement, ColorPickerInputPro
useThrottleFn( useThrottleFn(
(c) => { (c) => {
if (c === value) {
return;
}
// Default to an empty string if no color value is available
if (!c) {
onChange('');
return;
}
const color = theme.visualization.getColorByName(c); const color = theme.visualization.getColorByName(c);
if (returnColorAs === 'rgb') { if (returnColorAs === 'rgb') {
onChange(colorManipulator.asRgbString(color)); onChange(colorManipulator.asRgbString(color));

Loading…
Cancel
Save