Replies: 4 comments 14 replies
-
This is not an issue to the lib, if you submitted the form doesn't matter if it's the main/sub form. the submitted will be updated. there is only a single |
Beta Was this translation helpful? Give feedback.
-
This is due to nested form: <form>
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalBody>
<ModalForm onSuccess={onClose} />
</ModalBody>
</ModalContent>
</Modal>
</form> to <form>
...
</form>
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalBody>
<ModalForm onSuccess={onClose} />
</ModalBody>
</ModalContent>
</Modal> move the modal out should solve the problem. if you nested form element with form element, onSubmit will be triggered which leads to Work around (not recommend as it breaks accessbility)you can attach onClick with |
Beta Was this translation helpful? Give feedback.
-
I've fixed it temporarily. By adding <Portal>
<form
onSubmit={(e) => {
e.stopPropagation();
methods.handleSubmit(() => void 0)(e);
}}
/>
</Portal> If you'd like to address this, you can add So just to confirm it is a bug with RHF not preventing events propagating up the component chain in a valid HTML structure. |
Beta Was this translation helpful? Give feedback.
-
I had same problem, where I had to show multiple independent forms on the same page to be opened based on some conditions, some as sub-forms. The problem was seen when we submit one form, another form in dom used to get submitted.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Version Number
7.15.3
Codesandbox/Expo snack
https://codesandbox.io/s/holy-rain-nk0oq?file=/src/App.js
Steps to reproduce
useEffect
becauseisSubmitted
wrongly set to trueExpected behaviour
Main FormProvider's state should not be modified by child FormProvider's state.
isSubmitted
should stayfalsy
for main form when portal form is submitted.What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions