Events triggered on multiple forms on the same page
See original GitHub issueHi,
I have two forms in the same react component, and the onChange event in both forms are triggered when I change one of the forms. Here is the code:
import { Form } from 'react-formio'
const form1 = {
components: [
{
label: 'Input1',
type: 'textfield',
input: true,
key: 'input1',
},
],
display: 'form',
page: 0
}
const form2 = {
components: [
{
label: 'Input2',
type: 'textfield',
input: true,
key: 'input2',
},
],
display: 'form',
page: 0
}
class Container extends Component {
constructor(props) {
super(props)
}
onChange(event, id) {
console.log('onChange', id)
}
render() {
return (
<div>
<Form key='1' form={form1} onChange={(event) => this.onChange(event, '1')} />
<Form key='2' form={form2} onChange={(event) => this.onChange(event, '2')} />
</div>
)
}
}
export default Container
When I change “input1”, I am expecting to see only one event is triggered, however, two events are triggered and console prints out:
onChange 1
onChange 2
Why is the event for form 2 triggered? I also experience the same issue with the onSubmit event.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Is there any way to trigger a DOM event for multiple forms at ...
CF7 events bubble up through the document, so you can do something like this, let page = document.querySelector('body'); page.
Read more >Events triggered on multiple forms on the same page #149
Hi, I have two forms in the same react component, and the onChange event in both forms are triggered when I change one...
Read more >Multiple forms, same event? Here's how to track each form ...
Solution: We used a Lookup Table variable to give each form a different name, based on its form ID. In the Google analytics...
Read more >Two Forms, Two Actions, Same Page - PHP - W3Schools Forum
This strategy has led to the following two questions: QUESTION ONE: Under the assumption that one can have only one $_POST variable per...
Read more >Track Many Forms with One Thank You Page with Google Tag ...
Learn how to track multiple forms with one Thank you page. This guide covers various techniques and explains how to choose the best...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fix shared EventEmitter
Thanks! Can you please link the commit or PR to this issue? I would like to know the fix.