Skip to content

Commit

Permalink
Merge pull request #126 from indec-it/refactor/preventChanges
Browse files Browse the repository at this point in the history
refactor: fix  when press enter and change data with mousewheel
  • Loading branch information
maximilianoforlenza authored Aug 19, 2024
2 parents d90e198 + 2f9fdef commit a7f9609
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/FormBuilder/FormBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function FormBuilder({
onPrevious(values);
};

const handleKeyDown = keyEvent => {
if ((keyEvent.charCode || keyEvent.keyCode) === 13) {
keyEvent.preventDefault();
}
};

return (
<FormProvider section={transformedSection} sections={sections} initialValues={initialValues}>
<Formik
Expand All @@ -80,7 +86,7 @@ function FormBuilder({
}, [values, onChange, position]);

return (
<Form>
<Form onKeyDown={handleKeyDown}>
<FieldArray
name={section.name}
render={sectionHelpers =>
Expand Down
1 change: 1 addition & 0 deletions src/components/TextField/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function TextField({form, field, placeholder, label, disabled, tooltip, warnings
disabled={disabled}
multiline={multiline}
rows={multiline ? 2 : 1}
onWheel={e => e.target.blur()}
/>
<FieldMessage warnings={warnings} form={form} field={field} disabled={disabled} />
</Box>
Expand Down

0 comments on commit a7f9609

Please sign in to comment.