diff --git a/packages/solid/CHANGELOG.md b/packages/solid/CHANGELOG.md
index fb2eb9e6..54179424 100644
--- a/packages/solid/CHANGELOG.md
+++ b/packages/solid/CHANGELOG.md
@@ -8,6 +8,7 @@ All notable changes to the library will be documented in this file.
- Add `keepResponse` property to `Form` component
- Add `keepResponse` option to `handleSubmit` and `reset` method
- Refactor `reset` method
+- Add `keepItems` and `keepDirtyItems` option to `reset` method
## v0.4.0 (November 02, 2022)
diff --git a/packages/solid/src/methods/reset.ts b/packages/solid/src/methods/reset.ts
index 91a347ea..128083e8 100644
--- a/packages/solid/src/methods/reset.ts
+++ b/packages/solid/src/methods/reset.ts
@@ -29,6 +29,8 @@ type ResetOptions<
keepSubmitted: boolean;
keepValues: boolean;
keepDirtyValues: boolean;
+ keepItems: boolean;
+ keepDirtyItems: boolean;
keepErrors: boolean;
keepTouched: boolean;
keepDirty: boolean;
@@ -74,6 +76,8 @@ export function reset<
keepSubmitted = false,
keepValues = false,
keepDirtyValues = false,
+ keepItems = false,
+ keepDirtyItems = false,
keepErrors = false,
keepTouched = false,
keepDirty = false,
@@ -139,11 +143,11 @@ export function reset<
// Get specified field array
const fieldArray = getFieldArray(form, name);
- // Check if dirty value should be kept
- const keepDirtyValue = keepDirtyValues && fieldArray.getDirty();
+ // Check if current dirty items should be kept
+ const keepCurrentDirtyItems = keepDirtyItems && fieldArray.getDirty();
// Reset initial items and items if it is not to be kept
- if (!keepValues && !keepDirtyValue) {
+ if (!keepItems && !keepCurrentDirtyItems) {
const initialItems = getInitialItems(form, name);
fieldArray.setInitialItems(initialItems);
fieldArray.setItems(initialItems);
@@ -155,7 +159,7 @@ export function reset<
}
// Reset dirty if it is not to be kept
- if (!keepDirty && !keepValues && !keepDirtyValue) {
+ if (!keepDirty && !keepItems && !keepCurrentDirtyItems) {
fieldArray.setDirty(false);
}
diff --git a/packages/website/src/routes/api/reset.mdx b/packages/website/src/routes/api/reset.mdx
index f07bf239..3ffb3c35 100644
--- a/packages/website/src/routes/api/reset.mdx
+++ b/packages/website/src/routes/api/reset.mdx
@@ -35,6 +35,8 @@ reset(form, name, options);
- `keepSubmitted`
- `keepValues`
- `keepDirtyValues`
+ - `keepItems`
+ - `keepDirtyItems`
- `keepErrors`
- `keepTouched`
- `keepDirty`
@@ -51,7 +53,7 @@ When you reset a single field, you can specify a new `initialValue` that overrid
By default, the reactive `response`, `submitCount` and `submitted` state of the `form` is reset when the entire form is reset. To change this behavior you can set `keepResponse`, `keepSubmitCount` and/or `keepSubmitted` to `true`.
-By default, the `value`, `error`, `touched` and `dirty` state of each field and field array are reset. To change this behavior you can set `keepValues`, `keepDirtyValues`, `keepErrors`, `keepErrors` and/or `keepDirty` to `true`.
+By default, the `value`, `items`, `error`, `touched` and `dirty` state of each field and field array are reset. To change this behavior you can set `keepValues`, `keepDirtyValues`, `keepItems`, `keepDirtyItems`, `keepErrors`, `keepTouched` and/or `keepDirty` to `true`.
export const properties = {
form: {
@@ -117,6 +119,14 @@ export const properties = {
type: 'boolean',
defaultValue: { type: 'boolean', value: false },
},
+ keepItems: {
+ type: 'boolean',
+ defaultValue: { type: 'boolean', value: false },
+ },
+ keepDirtyItems: {
+ type: 'boolean',
+ defaultValue: { type: 'boolean', value: false },
+ },
keepErrors: {
type: 'boolean',
defaultValue: { type: 'boolean', value: false },