Skip to content

Commit 45441e9

Browse files
author
Pedro Lourenço
authored
Add modifiedSinceLastSubmit (#799)
1 parent 4d37306 commit 45441e9

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

docs/types/FieldRenderProps.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ Optional: May not be present if you have not [subscribed](FieldProps#subscriptio
144144

145145
Once `true`, it will remain `true` for the lifetime of the field, or until the form is reset.
146146

147+
## `meta.modifiedSinceLastSubmit`
148+
149+
```ts
150+
boolean
151+
```
152+
153+
Optional: May not be present if you have not [subscribed](FieldProps#subscription) to `modifiedSinceLastSubmit`.
154+
155+
`true` if this field's value has ever been changed since last submission. `false` otherwise.
156+
157+
Once `true`, it will remain `true` until the next submit action, or until the form is reset.
158+
147159
## `meta.pristine`
148160

149161
```ts

src/getters.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const addLazyFormState = (dest: Object, state: FormState): void =>
2323
'initialValues',
2424
'invalid',
2525
'modified',
26+
'modifiedSinceLastSubmit',
2627
'pristine',
2728
'submitError',
2829
'submitErrors',
@@ -47,6 +48,7 @@ export const addLazyFieldMetaState = (dest: Object, state: FieldState): void =>
4748
'invalid',
4849
'length',
4950
'modified',
51+
'modifiedSinceLastSubmit',
5052
'pristine',
5153
'submitError',
5254
'submitFailed',

src/types.js.flow

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type FieldRenderProps = {
3939
invalid?: boolean,
4040
length?: number,
4141
modified?: boolean,
42+
modifiedSinceLastSubmit?: boolean,
4243
pristine?: boolean,
4344
submitError?: any,
4445
submitFailed?: boolean,

src/useField.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('useField', () => {
4848
expect(meta.invalid).toBe(false)
4949
expect(meta.length).toBeUndefined()
5050
expect(meta.modified).toBe(false)
51+
expect(meta.modifiedSinceLastSubmit).toBe(false)
5152
expect(meta.pristine).toBe(true)
5253
expect(meta.submitError).toBeUndefined()
5354
expect(meta.submitFailed).toBe(false)

0 commit comments

Comments
 (0)