Skip to content

Commit

Permalink
Merge pull request #7715 from marmelab/7711-new-category-popover-save…
Browse files Browse the repository at this point in the history
…-button-submits-the-whole-form-instead-of-the-popover-form

Fix Form submit cannot be prevented with event.preventDefault
  • Loading branch information
fzaninotto authored May 19, 2022
2 parents c2d6bd5 + e88b3de commit f8bc921
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/ra-core/src/form/useAugmentedForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ export const useAugmentedForm = (props: UseAugmentedFormProps) => {

const formHandleSubmit = useCallback(
(event: BaseSyntheticEvent) => {
// Prevent outer forms to receive the event
event.stopPropagation();
form.handleSubmit(handleSubmit)(event);
if (!event.defaultPrevented) {
// Prevent outer forms to receive the event
event.stopPropagation();
form.handleSubmit(handleSubmit)(event);
}
return;
},
[form, handleSubmit]
Expand Down

0 comments on commit f8bc921

Please sign in to comment.