Skip to content

Commit 9ba7a52

Browse files
committed
fix type issues with react-color onChange props
1 parent ecfe6bd commit 9ba7a52

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/editor/src/ColorPicker.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ export const Picker = CustomPicker<CustomPickerForwardedProps>(
146146
value={round(props.hsl.h)}
147147
name="hue"
148148
label="h"
149-
onChange={val => {
150-
props.onChange({ ...props.hsl, ...val })
149+
// We need to cast to any because @types/react-color does not define types correctly
150+
onChange={({ h }: any) => {
151+
props.onChange({ ...props.hsl, h } as any)
151152
}}
152153
/>
153154
</Label>
@@ -158,9 +159,9 @@ export const Picker = CustomPicker<CustomPickerForwardedProps>(
158159
value={round(props.hsl.s * 100)}
159160
name="saturation"
160161
label="s"
161-
onChange={({ s }) => {
162-
// FIXME: props.onChange() incorrectly expects param to be ColorState instead of { h, s, l }.
163-
props.onChange({ ...props.hsl, s: s / 100 })
162+
// We need to cast to any because @types/react-color does not define types correctly
163+
onChange={({ s }: any) => {
164+
props.onChange({ ...props.hsl, s: s / 100 } as any)
164165
}}
165166
/>
166167
</Label>
@@ -171,9 +172,9 @@ export const Picker = CustomPicker<CustomPickerForwardedProps>(
171172
value={round(props.hsl.l * 100)}
172173
name="lightness"
173174
label="l"
174-
onChange={({ l }) => {
175-
// FIXME: props.onChange() incorrectly expects param to be ColorState instead of { h, s, l }.
176-
props.onChange({ ...props.hsl, l: l / 100 })
175+
// We need to cast to any because @types/react-color does not define types correctly
176+
onChange={({ l }: any) => {
177+
props.onChange({ ...props.hsl, l: l / 100 } as any)
177178
}}
178179
/>
179180
</Label>

0 commit comments

Comments
 (0)