@jsenv/navi 0.27.57 → 0.27.59

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.
@@ -14285,9 +14285,14 @@ This prevents cross-test pollution and ensures clean state.`,
14285
14285
  // 1. We're navigating within the same route family (not to completely unrelated routes)
14286
14286
  // 2. AND no matching route extracts this parameter from URL
14287
14287
  // 3. AND parameter has no default value (making it truly optional)
14288
+ // 4. AND parameter is a path segment (not a search param)
14289
+ // Search params represent user preferences/choices and must survive
14290
+ // navigation away — only path segments are explicitly removed from
14291
+ // the URL when the route stops matching.
14288
14292
  if (
14289
14293
  matchingRouteInSameFamily &&
14290
- !parameterExtractedByMatchingRoute
14294
+ !parameterExtractedByMatchingRoute &&
14295
+ pathConnectionMap.has(paramName)
14291
14296
  ) {
14292
14297
  const defaultValue = connection.getDefaultValue();
14293
14298
  if (defaultValue === undefined) {
@@ -14309,6 +14314,10 @@ This prevents cross-test pollution and ensures clean state.`,
14309
14314
  console.debug(
14310
14315
  `[route] Different route family: preserving ${paramName} signal value: ${paramSignal.value}`,
14311
14316
  );
14317
+ } else if (queryConnectionMap.has(paramName)) {
14318
+ console.debug(
14319
+ `[route] Search param ${paramName}: preserving signal value (user choice): ${paramSignal.value}`,
14320
+ );
14312
14321
  } else {
14313
14322
  console.debug(
14314
14323
  `[route] Parameter ${paramName} extracted by matching route: preserving signal value: ${paramSignal.value}`,
@@ -14718,8 +14727,15 @@ const setupBrowserIntegrationViaHistory = ({
14718
14727
  updateDocumentState(state);
14719
14728
  }
14720
14729
 
14721
- // Routes only match on URL — skip route matching for state-only changes.
14722
- if (isSameUrl && navigationType !== "reload" && navigationType !== "load") {
14730
+ // Skip route matching for state-only changes: push/replace to the same URL
14731
+ // (e.g. useNavState updating document state without changing the route).
14732
+ // Do NOT apply for "traverse" — window.location.href is already updated by
14733
+ // the browser before the popstate handler runs, so isSameUrl is always true
14734
+ // for back/forward navigation regardless of whether the URL actually changed.
14735
+ if (
14736
+ isSameUrl &&
14737
+ (navigationType === "push" || navigationType === "replace")
14738
+ ) {
14723
14739
  return undefined;
14724
14740
  }
14725
14741
 
@@ -35656,6 +35672,9 @@ const Dialog = props => {
35656
35672
  };
35657
35673
  closeRequestHandler(e, closePermission, detail);
35658
35674
  if (denied) {
35675
+ if (e.type === "cancel") {
35676
+ e.preventDefault();
35677
+ }
35659
35678
  closePermission.allow = () => {
35660
35679
  close(e, detail);
35661
35680
  };
@@ -35706,9 +35725,6 @@ const Dialog = props => {
35706
35725
  }
35707
35726
  },
35708
35727
  onCancel: e => {
35709
- // The browser fires "cancel" (then closes the dialog) when the user presses Escape.
35710
- // Prevent the native close so we control the close flow and dispatch navi_dialog_close.
35711
- e.preventDefault();
35712
35728
  onRequestClose(e);
35713
35729
  },
35714
35730
  onnavi_request_open: e => {