Skip to content

Commit 3d19e46

Browse files
committed
Add preventScrollReset to form docs
1 parent 07aa818 commit 3d19e46

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

docs/components/form.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,16 @@ See also:
215215
- [`useActionData`][useactiondata]
216216
- [`useSubmit`][usesubmit]
217217

218+
## `preventScrollReset`
219+
220+
If you are using [`<ScrollRestoration>`][scrollrestoration], this lets you prevent the scroll position from being reset to the top of the window when the form action redirects to a new location.
221+
222+
```tsx
223+
<Form method="post" preventScrollReset={true} />
224+
```
225+
226+
See also: [`<Link preventScrollReset>`][link-preventscrollreset]
227+
218228
# Examples
219229

220230
TODO: More examples
@@ -318,3 +328,5 @@ You can access those values from the `request.url`
318328
[formvalidation]: https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation
319329
[indexsearchparam]: ../guides/index-search-param
320330
[pickingarouter]: ../routers/picking-a-router
331+
[scrollrestoration]: ./scroll-restoration
332+
[link-preventscrollreset]: ./link#preventscrollreset

docs/components/scroll-restoration.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ Or you may want to only use the pathname for some paths, and use the normal beha
8383

8484
## Preventing Scroll Reset
8585

86-
When navigation creates new scroll keys, the scroll position is reset to the top of the page. You can prevent the "scroll to top" behavior from your links:
86+
When navigation creates new scroll keys, the scroll position is reset to the top of the page. You can prevent the "scroll to top" behavior from your links and forms:
8787

8888
```tsx
8989
<Link preventScrollReset={true} />
90+
<Form preventScrollReset={true} />
9091
```
9192

92-
See also: [`<Link preventScrollReset>`][preventscrollreset]
93+
See also: [`<Link preventScrollReset>`][preventscrollreset], [`<Form preventScrollReset>`][form-preventscrollreset]
9394

9495
## Scroll Flashing
9596

@@ -99,4 +100,5 @@ Server Rendering frameworks can prevent scroll flashing because they can send a
99100

100101
[remix]: https://remix.run
101102
[preventscrollreset]: ../components/link#preventscrollreset
103+
[form-preventscrollreset]: ../components/form#preventscrollreset
102104
[pickingarouter]: ../routers/picking-a-router

0 commit comments

Comments
 (0)