Skip to content

Commit

Permalink
Extends logic of PR redux-form#3460 to onFocus and onBlur. Also preve…
Browse files Browse the repository at this point in the history
…nts issue redux-form#3489 locking version of immutable
  • Loading branch information
jkomyno committed Oct 9, 2017
1 parent 19bd7cb commit 2cd10cb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"flow-bin": "^0.56.0",
"flux-standard-action": "^1.0.0",
"get-typed": "^1.0.0-beta.2",
"immutable": "^4.0.0-rc.3",
"immutable": "4.0.0-rc.3",
"jest": "^21.0.2",
"lodash-webpack-plugin": "^0.11.2",
"prettier": "^1.6.1",
Expand Down
46 changes: 28 additions & 18 deletions src/ConnectedField.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,19 @@ const createConnectedField = (structure: Structure<*, *>) => {
const { name, dispatch, onFocus, _reduxForm } = this.props

let defaultPrevented = false

if (onFocus) {
onFocus({
...event,
preventDefault: () => {
defaultPrevented = true
return eventPreventDefault(event)
}
})
if (!isReactNative) {
onFocus({
...event,
preventDefault: () => {
defaultPrevented = true
return eventPreventDefault(event)
}
})
} else {
onFocus(event)
}
}

if (!defaultPrevented) {
Expand Down Expand Up @@ -169,18 +174,23 @@ const createConnectedField = (structure: Structure<*, *>) => {
}

let defaultPrevented = false

if (onBlur) {
onBlur(
{
...event,
preventDefault: () => {
defaultPrevented = true
return eventPreventDefault(event)
}
},
newValue,
previousValue
)
if (!isReactNative) {
onBlur(
{
...event,
preventDefault: () => {
defaultPrevented = true
return eventPreventDefault(event)
}
},
newValue,
previousValue
)
} else {
onBlur(event, newValue, previousValue)
}
}

if (!defaultPrevented) {
Expand Down

0 comments on commit 2cd10cb

Please sign in to comment.