Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: forward NavigateOptions in adaptForAppRouterInstance (#52498)
### Fixing a bug ### What? App-router now supports the [`scroll`-option](https://github.com/vercel/next.js/pull/51869/files). Thank you for that! We're in the midst of migrating towards the app-router meaning that some pages use the `adaptForAppRouterInstance`-adapter. We noticed that the adaptForAppRouterInstance does not forward any options given to either `push` or `replace`, while in theory `{ scroll?: boolean }` perfectly overlaps and could be forwarded. ### Why? When using `{ scroll: false }` and using `adaptForAppRouterInstance` the options are not being forwarded. Meaning that when calling either `push` or `replace`, the page is scrolled to the top regardless. ### How? By forwarding the options that perfectly overlap between `NavigateOptions` (app-router) and `TransitionOptions` (next-router) ``` // Added NavigateOptions, and forward `{ scroll }` push(href: string, { scroll }:NavigateOptions = {}): void { void router.push(href, undefined, { scroll }) // }, replace(href: string, { scroll }:NavigateOptions = {}): void { void router.replace(href, undefined, { scroll }) }, ``` Please let me know if I need to change anything! Co-authored-by: Jeffrey <jeffrey@jeffreyzutt.nl> Co-authored-by: Jimmy Lai <laijimmy0@gmail.com>
- Loading branch information