diff --git a/.changeset/reset-listeners.md b/.changeset/reset-listeners.md new file mode 100644 index 000000000..c7a303c47 --- /dev/null +++ b/.changeset/reset-listeners.md @@ -0,0 +1,5 @@ +--- +'@tanstack/form-core': minor +--- + +Add `onReset` listener support for forms and fields, add `reset` method to `FieldApi`, and expand `ListenerCause` type with `'reset'` and `'unmount'` values diff --git a/docs/framework/angular/guides/listeners.md b/docs/framework/angular/guides/listeners.md index 729e00a86..ee444354a 100644 --- a/docs/framework/angular/guides/listeners.md +++ b/docs/framework/angular/guides/listeners.md @@ -20,6 +20,7 @@ Events that can be "listened" to are: - `onMount` - `onSubmit` - `onUnmount` +- `onReset` ```angular-ts @Component({ diff --git a/docs/framework/react/guides/listeners.md b/docs/framework/react/guides/listeners.md index f42cb6dcd..5e6a5746c 100644 --- a/docs/framework/react/guides/listeners.md +++ b/docs/framework/react/guides/listeners.md @@ -13,13 +13,14 @@ Imagine the following user flow: In this example, when the user changes the country, the selected province needs to be reset as it's no longer valid. With the listener API, we can subscribe to the `onChange` event and dispatch a reset to the "province" field when the listener is fired. -Events that can be "listened" to are: +Field level events that can be "listened" to are: - `onChange` - `onBlur` - `onMount` - `onSubmit` - `onUnmount` +- `onReset` ```tsx function App() { @@ -93,9 +94,9 @@ We enable an easy method for debouncing your listeners by adding a `onChangeDebo ### Form listeners -At a higher level, listeners are also available at the form level, allowing you access to the `onMount` and `onSubmit` events, and having `onChange` and `onBlur` propagated to all the form's children. Form-level listeners can also be debounced in the same way as previously discussed. +At a higher level, listeners are also available at the form level, allowing you access to the `onMount`, `onSubmit`, and `onReset` events, and having `onChange` and `onBlur` propagated to all the form's children. Form-level listeners can also be debounced in the same way as previously discussed. -`onMount` and `onSubmit` listeners have the following parameters: +`onMount`, `onSubmit`, `onReset` listeners have the following parameters: - `formApi` diff --git a/docs/framework/vue/guides/listeners.md b/docs/framework/vue/guides/listeners.md index 946af1e7f..b3dda0390 100644 --- a/docs/framework/vue/guides/listeners.md +++ b/docs/framework/vue/guides/listeners.md @@ -20,6 +20,7 @@ Events that can be "listened" to are: - `onMount` - `onSubmit` - `onUnmount` +- `onReset` ```vue