event.preventDefault is not a function in onChange(event, value, previousValue, name)
See original GitHub issueafter upgrade react-redux
to version 7.1.1
and redux-form
to version 8.2.6
…
i found that preventDefault object is missing from the event params…
Here is my code…
<Field
component={ReduxFormRadioGroup}
formItemProps={{ className: 'operation-hours__option-container' }}
label='Hours of Operation'
name='operationHoursCategory'
onChange={this.handleCategoryChange}
/>
handleDisabledDayChange = (event, value, previousValue, name) => {
console.log(event, value, previousValue, name)
event.preventDefault()
...
.......
}
in "redux-form": "^7.2.0"
and "react-redux": "^5.0.7"
:
console.log(event) can see the preventDefault: ƒ preventDefault()
in redux-form": "^8.2.6"
and "react-redux": "^7.1.1"
:
console.log(event) do not have preventDefault: ƒ preventDefault()
this in result event.preventDefault()
is not a function and break the application!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (2 by maintainers)
Top Results From Across the Web
preventDefault() not working for change event - Stack Overflow
You can't use preventDefault on change events because it's not cancelable: $("#text1").change(function(e) { alert(e.cancelable?
Read more >Field - Redux Form
preventDefault () , the BLUR action will NOT be dispatched, and the value and focus state will not be updated in the Redux...
Read more >Event.preventDefault() - Web APIs | MDN
The preventDefault() method of the Event interface tells the user agent that if the event does not get explicitly handled, its default ...
Read more >w2grid.onChange | JavaScript UI - w2ui
Hi Vitmalina,. Why is the name of the field not provided in the event ? The event gives the recid, the previous value...
Read more >Handle the Value Change Event - DevExtreme - DevExpress
If the handling function is not going to be changed during the lifetime of the UI component, assign it to the onValueChanged property...
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 Free
Top 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
8.3.0
did not fix the problem for me.For many of my inputs, I’m calling
input.onChange(value)
with the value of the input as the argument. These are the inputs that cause the problem. When anonChange
is passed to the<Field />
from above these inputs, the first argument injected into the Field’s onChange is the value, not the event. Then there is no way to cancel the change event.It is possible to fix this by updating my inputs to call
input.onChange(event)
with the event instead of the value as the first argument. Then any Field.onChange handlers will receive the event. However, this isn’t ideal for some inputs because the value that is attached to the change event is not always the value that I would like to propagate.There are likely ways to work around this, but it seems like this wasn’t an intended change. Or if it was, the documentation should at least make it clear that in order to receive the event in the Field.onchange handler, you need to pass an event to input.onChange from within the input.
Just want to note, this is still an issue in 8.3.7
Appreciate any work being put into this 😃