Skip to content

Commit a2e2537

Browse files
authored
fix(onchange callback): change sending event instead of value (#95)
1 parent cf20cbf commit a2e2537

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

packages/insights-common-typescript/src/components/Formik/Patternfly/Common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react';
22
import { FieldInputProps } from 'formik';
33

4-
export const onChangePFAdapter = <T = React.FormEvent<HTMLInputElement>, E = boolean>(field: FieldInputProps<T>) => {
5-
return (_: T, e: E) => {
4+
export const onChangePFAdapter = <T = React.FormEvent<HTMLInputElement>>(field: FieldInputProps<T>) => {
5+
return (e: T) => {
66
return field.onChange(e);
77
};
88
};

packages/insights-common-typescript/src/components/Formik/Patternfly/FormSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const FormSelect: React.FunctionComponent<FormSelectProps> = (props) => {
2828
<PFFormSelect
2929
{ ...withoutOuiaProps(props) }
3030
{ ...field }
31-
onChange={ onChangePFAdapter<React.FormEvent<HTMLSelectElement>, string | number>(field) }
31+
onChange={ onChangePFAdapter<React.FormEvent<HTMLSelectElement>>(field) }
3232
isRequired={ props.isRequired }
3333
validated={ (isValid) ? 'default' : 'error' }
3434
>

packages/insights-common-typescript/src/components/Formik/Patternfly/FormTextArea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const FormTextArea: React.FunctionComponent<FormTextAreaProps> = (props)
3131
value={ field.value || '' }
3232
validated={ (isValid) ? 'default' : 'error' }
3333
isRequired={ props.isRequired }
34-
onChange={ onChangePFAdapter<React.FormEvent<HTMLTextAreaElement>, string | number>(field) }
34+
onChange={ onChangePFAdapter<React.FormEvent<HTMLTextAreaElement>>(field) }
3535
/>
3636
{meta.error && <FormHelperText>
3737
<HelperText>

packages/insights-common-typescript/src/components/Formik/Patternfly/FormTextInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const FormTextInput: React.FunctionComponent<FormTextInputProps> = (props
3333
{ ...field }
3434
validated={ (isValid) ? 'default' : 'error' }
3535
value={ field.value !== undefined ? field.value.toString() : '' }
36-
onChange={ onChangePFAdapter<React.FormEvent<HTMLInputElement>, string | number>(field) }
36+
onChange={ onChangePFAdapter<React.FormEvent<HTMLInputElement>>(field) }
3737
/>
3838
{ hint && <Text component={ TextVariants.small }>{ hint }</Text> }
3939
{meta.error && <FormHelperText>

packages/insights-common-typescript/src/components/Formik/Patternfly/Switch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const Switch: React.FunctionComponent<SwitchProps> = (props) => {
3434
ouiaId="pf-switch"
3535
ouiaSafe={ props.ouiaSafe }
3636
label={ label }
37-
onChange={ onChangePFAdapter<React.FormEvent<HTMLInputElement>, boolean>(field) }
37+
onChange={ onChangePFAdapter<React.FormEvent<HTMLInputElement>>(field) }
3838
/>
3939
{meta.error && <FormHelperText>
4040
<HelperText>

0 commit comments

Comments
 (0)