@remix-run/router 1.3.0-pre.0 → 1.3.0-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # `@remix-run/router`
2
2
 
3
+ ## 1.3.0-pre.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix scroll reset if a submission redirects ([#9886](https://github.com/remix-run/react-router/pull/9886))
8
+
3
9
  ## 1.3.0-pre.0
4
10
 
5
11
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v1.3.0-pre.0
2
+ * @remix-run/router v1.3.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1590,7 +1590,7 @@ function createRouter(init) {
1590
1590
 
1591
1591
 
1592
1592
  function completeNavigation(location, newState) {
1593
- var _location$state;
1593
+ var _location$state, _location$state2;
1594
1594
 
1595
1595
  // Deduce if we're in a loading/actionReload state:
1596
1596
  // - We have committed actionData in the store
@@ -1616,7 +1616,10 @@ function createRouter(init) {
1616
1616
  } // Always preserve any existing loaderData from re-used routes
1617
1617
 
1618
1618
 
1619
- let loaderData = newState.loaderData ? mergeLoaderData(state.loaderData, newState.loaderData, newState.matches || [], newState.errors) : state.loaderData;
1619
+ let loaderData = newState.loaderData ? mergeLoaderData(state.loaderData, newState.loaderData, newState.matches || [], newState.errors) : state.loaderData; // Always respect the user flag. Otherwise don't reset on mutation
1620
+ // submission navigations unless they redirect
1621
+
1622
+ let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && ((_location$state2 = location.state) == null ? void 0 : _location$state2._isRedirect) !== true;
1620
1623
  updateState(_extends({}, newState, {
1621
1624
  // matches, errors, fetchers go through as-is
1622
1625
  actionData,
@@ -1626,9 +1629,8 @@ function createRouter(init) {
1626
1629
  initialized: true,
1627
1630
  navigation: IDLE_NAVIGATION,
1628
1631
  revalidation: "idle",
1629
- // Don't restore on submission navigations
1630
- restoreScrollPosition: state.navigation.formData ? false : getSavedScrollPosition(location, newState.matches || state.matches),
1631
- preventScrollReset: pendingPreventScrollReset
1632
+ restoreScrollPosition: getSavedScrollPosition(location, newState.matches || state.matches),
1633
+ preventScrollReset
1632
1634
  }));
1633
1635
 
1634
1636
  if (isUninterruptedRevalidation) ; else if (pendingAction === exports.Action.Pop) ; else if (pendingAction === exports.Action.Push) {
@@ -2452,7 +2454,9 @@ function createRouter(init) {
2452
2454
  await startNavigation(redirectHistoryAction, redirectLocation, {
2453
2455
  submission: _extends({}, submission, {
2454
2456
  formAction: redirect.location
2455
- })
2457
+ }),
2458
+ // Preserve this flag across redirects
2459
+ preventScrollReset: pendingPreventScrollReset
2456
2460
  });
2457
2461
  } else {
2458
2462
  // Otherwise, we kick off a new loading navigation, preserving the
@@ -2465,7 +2469,9 @@ function createRouter(init) {
2465
2469
  formAction: submission ? submission.formAction : undefined,
2466
2470
  formEncType: submission ? submission.formEncType : undefined,
2467
2471
  formData: submission ? submission.formData : undefined
2468
- }
2472
+ },
2473
+ // Preserve this flag across redirects
2474
+ preventScrollReset: pendingPreventScrollReset
2469
2475
  });
2470
2476
  }
2471
2477
  }