From 3cf598b243647a36783a91de22db3abfa722de92 Mon Sep 17 00:00:00 2001 From: Albert Folch Date: Wed, 30 Oct 2024 09:25:27 +0100 Subject: [PATCH] fix: build --- .../react-kit/src/components/form/Select.tsx | 18 +++++++++++------- .../react-kit/src/components/form/types.ts | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/react-kit/src/components/form/Select.tsx b/packages/react-kit/src/components/form/Select.tsx index 4826108ef..c1cf5d155 100644 --- a/packages/react-kit/src/components/form/Select.tsx +++ b/packages/react-kit/src/components/form/Select.tsx @@ -125,6 +125,16 @@ export default function SelectComponent({ const displayError = typeof displayErrorMessage === "string" && displayErrorMessage !== ""; + const handleChange = ( + option: Parameters>[0], + actionMeta: Parameters>[1] + ) => { + if (!meta.touched) { + helpers.setTouched(true); + } + helpers.setValue(option); + onChange?.(option, actionMeta); + }; const handleBlur = () => { if (!meta.touched) { helpers.setTouched(true); @@ -141,13 +151,7 @@ export default function SelectComponent({ placeholder={placeholder} options={options} value={field.value} - onChange={(option, ...rest) => { - if (!meta.touched) { - helpers.setTouched(true); - } - helpers.setValue(option); - onChange?.(option, ...rest); - }} + onChange={handleChange} onBlur={handleBlur} isSearchable={isSearchable} isClearable={isClearable} diff --git a/packages/react-kit/src/components/form/types.ts b/packages/react-kit/src/components/form/types.ts index 8a4c57d15..7ba84f92a 100644 --- a/packages/react-kit/src/components/form/types.ts +++ b/packages/react-kit/src/components/form/types.ts @@ -1,5 +1,5 @@ import { ReactNode } from "react"; -import Select, { +import { ActionMeta, CSSObjectWithLabel, MultiValue, @@ -103,7 +103,7 @@ export type SelectProps = BaseProps & { option: M extends true ? MultiValue> : SingleValue>, - actionMeta: ActionMeta> + actionMeta?: ActionMeta> ) => void; label?: string; theme?: Partial<{