From 08ce3661401c9797010d0a6d1f2fca950b6941ba Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 7 Nov 2022 14:24:01 +0100 Subject: [PATCH 1/2] Fix scrolling on router.refresh --- packages/next/client/components/reducer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/next/client/components/reducer.ts b/packages/next/client/components/reducer.ts index e779e439a4b48e2..fb12318944fcf89 100644 --- a/packages/next/client/components/reducer.ts +++ b/packages/next/client/components/reducer.ts @@ -1112,6 +1112,7 @@ function clientReducer( tree: tree, } } + // TODO-APP: Add test for not scrolling to nearest layout when calling refresh. case ACTION_REFRESH: { const { cache, mutable } = action const href = state.canonicalUrl @@ -1151,7 +1152,7 @@ function clientReducer( pushRef: state.pushRef, // Apply focus and scroll. // TODO-APP: might need to disable this for Fast Refresh. - focusAndScrollRef: { apply: true }, + focusAndScrollRef: { apply: false }, cache: cache, prefetchCache: state.prefetchCache, tree: mutable.patchedTree, From 3fa76abdd183ba0a66bfccc3117f38bc82024d12 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 7 Nov 2022 14:27:20 +0100 Subject: [PATCH 2/2] Add another todo --- packages/next/client/components/reducer.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/next/client/components/reducer.ts b/packages/next/client/components/reducer.ts index fb12318944fcf89..074deb8acaa71c3 100644 --- a/packages/next/client/components/reducer.ts +++ b/packages/next/client/components/reducer.ts @@ -1113,6 +1113,7 @@ function clientReducer( } } // TODO-APP: Add test for not scrolling to nearest layout when calling refresh. + // TODO-APP: Add test for startTransition(() => {router.push('/'); router.refresh();}), that case should scroll. case ACTION_REFRESH: { const { cache, mutable } = action const href = state.canonicalUrl