@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.
@@ -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
  *
@@ -1592,7 +1592,7 @@
1592
1592
 
1593
1593
 
1594
1594
  function completeNavigation(location, newState) {
1595
- var _location$state;
1595
+ var _location$state, _location$state2;
1596
1596
 
1597
1597
  // Deduce if we're in a loading/actionReload state:
1598
1598
  // - We have committed actionData in the store
@@ -1618,7 +1618,10 @@
1618
1618
  } // Always preserve any existing loaderData from re-used routes
1619
1619
 
1620
1620
 
1621
- let loaderData = newState.loaderData ? mergeLoaderData(state.loaderData, newState.loaderData, newState.matches || [], newState.errors) : state.loaderData;
1621
+ 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
1622
+ // submission navigations unless they redirect
1623
+
1624
+ let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && ((_location$state2 = location.state) == null ? void 0 : _location$state2._isRedirect) !== true;
1622
1625
  updateState(_extends({}, newState, {
1623
1626
  // matches, errors, fetchers go through as-is
1624
1627
  actionData,
@@ -1628,9 +1631,8 @@
1628
1631
  initialized: true,
1629
1632
  navigation: IDLE_NAVIGATION,
1630
1633
  revalidation: "idle",
1631
- // Don't restore on submission navigations
1632
- restoreScrollPosition: state.navigation.formData ? false : getSavedScrollPosition(location, newState.matches || state.matches),
1633
- preventScrollReset: pendingPreventScrollReset
1634
+ restoreScrollPosition: getSavedScrollPosition(location, newState.matches || state.matches),
1635
+ preventScrollReset
1634
1636
  }));
1635
1637
 
1636
1638
  if (isUninterruptedRevalidation) ; else if (pendingAction === exports.Action.Pop) ; else if (pendingAction === exports.Action.Push) {
@@ -2454,7 +2456,9 @@
2454
2456
  await startNavigation(redirectHistoryAction, redirectLocation, {
2455
2457
  submission: _extends({}, submission, {
2456
2458
  formAction: redirect.location
2457
- })
2459
+ }),
2460
+ // Preserve this flag across redirects
2461
+ preventScrollReset: pendingPreventScrollReset
2458
2462
  });
2459
2463
  } else {
2460
2464
  // Otherwise, we kick off a new loading navigation, preserving the
@@ -2467,7 +2471,9 @@
2467
2471
  formAction: submission ? submission.formAction : undefined,
2468
2472
  formEncType: submission ? submission.formEncType : undefined,
2469
2473
  formData: submission ? submission.formData : undefined
2470
- }
2474
+ },
2475
+ // Preserve this flag across redirects
2476
+ preventScrollReset: pendingPreventScrollReset
2471
2477
  });
2472
2478
  }
2473
2479
  }