Skip to content

Commit 416aa6a

Browse files
authored
In GradientSlider - make sure to pass only initialValue to Slider (#1456)
1 parent 953a72b commit 416aa6a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

generatedTypes/components/slider/GradientSlider.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ declare type GradientSliderComponentProps = {
4747
} & GradientSliderProps & typeof defaultProps;
4848
interface GradientSliderState {
4949
color: tinycolor.ColorFormats.HSLA;
50+
initialColor: tinycolor.ColorFormats.HSLA;
5051
prevColor: string | undefined;
5152
}
5253
declare const defaultProps: {

src/components/slider/GradientSlider.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ type GradientSliderComponentProps = {
5959

6060
interface GradientSliderState {
6161
color: tinycolor.ColorFormats.HSLA;
62+
initialColor: tinycolor.ColorFormats.HSLA;
6263
prevColor: string | undefined;
6364
}
6465

@@ -85,6 +86,7 @@ class GradientSlider extends Component<GradientSliderComponentProps, GradientSli
8586

8687
this.state = {
8788
prevColor: props.color,
89+
initialColor: Colors.getHSL(props.color),
8890
color: Colors.getHSL(props.color)
8991
};
9092
}
@@ -186,6 +188,7 @@ class GradientSlider extends Component<GradientSliderComponentProps, GradientSli
186188

187189
render() {
188190
const {type, containerStyle, disabled, accessible} = this.props;
191+
const initialColor = this.state.initialColor;
189192
const color = this.getColor();
190193
const thumbTintColor = Colors.getHexString(color);
191194
let step = 0.01;
@@ -198,17 +201,17 @@ class GradientSlider extends Component<GradientSliderComponentProps, GradientSli
198201
case GradientSliderTypes.HUE:
199202
step = 1;
200203
maximumValue = 359;
201-
value = color.h;
204+
value = initialColor.h;
202205
renderTrack = this.renderHueGradient;
203206
onValueChange = this.updateHue;
204207
break;
205208
case GradientSliderTypes.LIGHTNESS:
206-
value = color.l;
209+
value = initialColor.l;
207210
renderTrack = this.renderLightnessGradient;
208211
onValueChange = this.updateLightness;
209212
break;
210213
case GradientSliderTypes.SATURATION:
211-
value = color.s;
214+
value = initialColor.s;
212215
renderTrack = this.renderSaturationGradient;
213216
onValueChange = this.updateSaturation;
214217
break;

0 commit comments

Comments
 (0)