diff --git a/striker-ui/components/InputWithRef.tsx b/striker-ui/components/InputWithRef.tsx index d32e42c2..eb3bf9e2 100644 --- a/striker-ui/components/InputWithRef.tsx +++ b/striker-ui/components/InputWithRef.tsx @@ -58,15 +58,19 @@ const InputWithRef = forwardRef( }: InputWithRefProps, ref: ForwardedRef>, ) => { + const { + props: { onChange: initOnChange, value: initValue, ...restInitProps }, + } = input; + const [value, setValue] = useState( - input.props.value ?? MAP_TO_INITIAL_VALUE[valueType], + initValue ?? MAP_TO_INITIAL_VALUE[valueType], ) as [MapToType[TypeName], MapToStateSetter[TypeName]]; const [isChangedByUser, setIsChangedByUser] = useState(false); const onChange = createInputOnChangeHandler({ postSet: (...args) => { setIsChangedByUser(true); - input.props.onChange?.call(null, ...args); + initOnChange?.call(null, ...args); postSetAppend?.call(null, ...args); }, set: setValue, @@ -84,7 +88,7 @@ const InputWithRef = forwardRef( [isChangedByUser, value], ); - return cloneElement(input, { ...input.props, onChange, value }); + return cloneElement(input, { ...restInitProps, onChange, value }); }, );