-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed myriad bugs with moving field state (#35)
- Loading branch information
Showing
10 changed files
with
168 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// @flow | ||
import type { MutableState } from 'final-form' | ||
|
||
function moveFieldState( | ||
state: MutableState<any>, | ||
source: Object, | ||
destKey: string, | ||
oldState: MutableState<any> = state | ||
) { | ||
state.fields[destKey] = { | ||
...source, | ||
name: destKey, | ||
// prevent functions from being overwritten | ||
// if the state.fields[destKey] does not exist, it will be created | ||
// when that field gets registered, with its own change/blur/focus callbacks | ||
change: oldState.fields[destKey] && oldState.fields[destKey].change, | ||
blur: oldState.fields[destKey] && oldState.fields[destKey].blur, | ||
focus: oldState.fields[destKey] && oldState.fields[destKey].focus, | ||
lastFieldState: undefined // clearing lastFieldState forces renotification | ||
} | ||
} | ||
|
||
export default moveFieldState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.