Skip to content

Commit 13fb8cb

Browse files
committed
🐛 Check on the whole palette configuration to refresh local state
1 parent e8b62fb commit 13fb8cb

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

x-pack/plugins/lens/public/shared_components/coloring/color_stops.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import useUnmount from 'react-use/lib/useUnmount';
2222
import { DEFAULT_COLOR } from './constants';
2323
import { getDataMinMax, getStepValue, isValidColor } from './utils';
2424
import { TooltipWrapper, useDebouncedValue } from '../index';
25-
import { ColorStop } from './types';
25+
import { ColorStop, CustomPaletteParams } from './types';
2626

2727
const idGeneratorFn = htmlIdGenerator();
2828

@@ -43,19 +43,15 @@ function shouldSortStops(colorStops: Array<{ color: string; stop: string | numbe
4343
export interface CustomStopsProps {
4444
colorStops: ColorStop[];
4545
onChange: (colorStops: ColorStop[]) => void;
46-
rangeType: 'number' | 'percent';
4746
dataBounds: { min: number; max: number };
48-
reverse?: boolean;
49-
palette?: string;
47+
paletteConfiguration: CustomPaletteParams | undefined;
5048
'data-test-prefix': string;
5149
}
5250
export const CustomStops = ({
5351
colorStops,
5452
onChange,
55-
rangeType,
53+
paletteConfiguration,
5654
dataBounds,
57-
reverse,
58-
palette,
5955
['data-test-prefix']: dataTestPrefix,
6056
}: CustomStopsProps) => {
6157
const onChangeWithValidation = useCallback(
@@ -76,7 +72,7 @@ export const CustomStops = ({
7672
id: idGeneratorFn(),
7773
}));
7874
// eslint-disable-next-line react-hooks/exhaustive-deps
79-
}, [palette, reverse]);
75+
}, [paletteConfiguration?.name, paletteConfiguration?.reverse, paletteConfiguration?.rangeType]);
8076

8177
const { inputValue: localColorStops, handleInputChange: setLocalColorStops } = useDebouncedValue({
8278
onChange: onChangeWithValidation,
@@ -101,6 +97,8 @@ export const CustomStops = ({
10197
}
10298
});
10399

100+
const rangeType = paletteConfiguration?.rangeType || 'percent';
101+
104102
return (
105103
<>
106104
{sortedReason ? (

x-pack/plugins/lens/public/shared_components/coloring/palette_configuration.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export function CustomizablePalette({
6767
setPalette: (palette: PaletteOutput<CustomPaletteParams>) => void;
6868
dataBounds: { min: number; max: number };
6969
}) {
70-
const rangeType = activePalette.params?.rangeType ?? defaultPaletteParams.rangeType;
7170
const isCurrentPaletteCustom = activePalette.params?.name === CUSTOM_PALETTE;
7271

7372
const colorStopsToShow = roundStopValues(
@@ -315,11 +314,9 @@ export function CustomizablePalette({
315314
}
316315
>
317316
<CustomStops
318-
reverse={activePalette.params?.reverse}
319-
palette={activePalette.params?.name}
317+
paletteConfiguration={activePalette?.params}
320318
data-test-prefix="lnsDatatable"
321319
colorStops={colorStopsToShow}
322-
rangeType={rangeType}
323320
dataBounds={dataBounds}
324321
onChange={(colorStops) => {
325322
const newParams = getSwitchToCustomParams(

0 commit comments

Comments
 (0)