@yuneta/gobj-ui 7.26.2 → 7.26.3

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.
@@ -2699,6 +2699,31 @@ function yui_shell_last_route_under(shell_gobj, route) {
2699
2699
  return route;
2700
2700
  }
2701
2701
  /************************************************************
2702
+ * Where the reader last was OUTSIDE `route`: the most recent
2703
+ * visited route that is neither `route` nor below it, or "" when
2704
+ * there is none (the page landed there and never left).
2705
+ *
2706
+ * It is the other half of yui_shell_last_route_under(), and it is
2707
+ * what a "back" button of a view means: the view the reader CAME
2708
+ * FROM, wherever that was. Browser Back already does that; a
2709
+ * button that names one fixed route instead only agrees with it
2710
+ * when the reader happened to come from there. Excluding the
2711
+ * whole subtree is the point -- going from one record of a detail
2712
+ * view to the next must not make "back" step through them.
2713
+ *
2714
+ * Like the other memories, a mirror of the url for the page: the
2715
+ * caller decides what to do with "" (a fixed fallback, usually).
2716
+ ************************************************************/
2717
+ function yui_shell_last_route_outside(shell_gobj, route) {
2718
+ let priv = shell_gobj && shell_gobj.priv;
2719
+ if (!priv || !(0, _yuneta_gobj_js.is_array)(priv.route_mru) || !route) return "";
2720
+ for (let i = priv.route_mru.length - 1; i >= 0; i--) {
2721
+ let r = priv.route_mru[i];
2722
+ if (r !== route && r.indexOf(route + "/") !== 0) return r;
2723
+ }
2724
+ return "";
2725
+ }
2726
+ /************************************************************
2702
2727
  * Resolve the shell that governs `gobj`: the nearest
2703
2728
  * C_YUI_SHELL ancestor, else the last shell created on the
2704
2729
  * page (apps have exactly one). Null when no shell exists —
@@ -23944,10 +23969,10 @@ function build_ui$6(gobj) {
23944
23969
  "button",
23945
23970
  {
23946
23971
  class: "button TREEDB_TOPICS_BACK is-hidden",
23947
- title: (0, i18next.t)("topics"),
23948
- "aria-label": (0, i18next.t)("topics"),
23949
- "data-i18n-title": "topics",
23950
- "data-i18n-aria-label": "topics"
23972
+ title: (0, i18next.t)("back"),
23973
+ "aria-label": (0, i18next.t)("back"),
23974
+ "data-i18n-title": "back",
23975
+ "data-i18n-aria-label": "back"
23951
23976
  },
23952
23977
  [[
23953
23978
  "span",
@@ -23955,8 +23980,8 @@ function build_ui$6(gobj) {
23955
23980
  [yui_toolbar_icon("yi-arrow-left")]
23956
23981
  ], [
23957
23982
  "span",
23958
- { i18n: "topics" },
23959
- "topics"
23983
+ { i18n: "back" },
23984
+ "back"
23960
23985
  ]],
23961
23986
  { click: (evt) => {
23962
23987
  evt.stopPropagation();
@@ -25605,9 +25630,27 @@ function ac_set_landing_view(gobj, event, kw, src) {
25605
25630
  return 0;
25606
25631
  }
25607
25632
  /************************************************************
25608
- * Back from a topic to the cards-landing grid (the section index).
25633
+ * Back from a topic to WHERE THE READER WAS.
25634
+ *
25635
+ * Browser Back and this button must land on the same place, or the
25636
+ * reader cannot tell which one to trust (2026-10-10). The button went to
25637
+ * the landing whatever came before it, so "linked records" from
25638
+ * `device_types` opened `devices`, and the arrow then showed the cards
25639
+ * instead of `device_types`, where Back went.
25640
+ *
25641
+ * So it asks the shell for the last route outside the topic on screen
25642
+ * (yui_shell_last_route_outside): the previous topic, the landing, or
25643
+ * the view the reader came from. With none -- the page landed on this
25644
+ * topic -- it goes to the landing, as before.
25609
25645
  ************************************************************/
25610
25646
  function ac_back_to_topics(gobj, event, kw, src) {
25647
+ let shell = yui_shell_of(gobj);
25648
+ let here = shell ? (0, _yuneta_gobj_js.gobj_read_attr)(shell, "current_route") || "" : "";
25649
+ let came_from = here ? yui_shell_last_route_outside(shell, here) : "";
25650
+ if (came_from) {
25651
+ yui_shell_navigate(shell, came_from, { push: true });
25652
+ return 0;
25653
+ }
25611
25654
  let routes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "landing_routes");
25612
25655
  let href = (0, _yuneta_gobj_js.is_object)(routes) ? routes[gobj.priv._landing_view] : null;
25613
25656
  if (href && typeof window !== "undefined") {
@@ -2694,6 +2694,31 @@ function yui_shell_last_route_under(shell_gobj, route) {
2694
2694
  return route;
2695
2695
  }
2696
2696
  /************************************************************
2697
+ * Where the reader last was OUTSIDE `route`: the most recent
2698
+ * visited route that is neither `route` nor below it, or "" when
2699
+ * there is none (the page landed there and never left).
2700
+ *
2701
+ * It is the other half of yui_shell_last_route_under(), and it is
2702
+ * what a "back" button of a view means: the view the reader CAME
2703
+ * FROM, wherever that was. Browser Back already does that; a
2704
+ * button that names one fixed route instead only agrees with it
2705
+ * when the reader happened to come from there. Excluding the
2706
+ * whole subtree is the point -- going from one record of a detail
2707
+ * view to the next must not make "back" step through them.
2708
+ *
2709
+ * Like the other memories, a mirror of the url for the page: the
2710
+ * caller decides what to do with "" (a fixed fallback, usually).
2711
+ ************************************************************/
2712
+ function yui_shell_last_route_outside(shell_gobj, route) {
2713
+ let priv = shell_gobj && shell_gobj.priv;
2714
+ if (!priv || !is_array(priv.route_mru) || !route) return "";
2715
+ for (let i = priv.route_mru.length - 1; i >= 0; i--) {
2716
+ let r = priv.route_mru[i];
2717
+ if (r !== route && r.indexOf(route + "/") !== 0) return r;
2718
+ }
2719
+ return "";
2720
+ }
2721
+ /************************************************************
2697
2722
  * Resolve the shell that governs `gobj`: the nearest
2698
2723
  * C_YUI_SHELL ancestor, else the last shell created on the
2699
2724
  * page (apps have exactly one). Null when no shell exists —
@@ -23939,10 +23964,10 @@ function build_ui$6(gobj) {
23939
23964
  "button",
23940
23965
  {
23941
23966
  class: "button TREEDB_TOPICS_BACK is-hidden",
23942
- title: t("topics"),
23943
- "aria-label": t("topics"),
23944
- "data-i18n-title": "topics",
23945
- "data-i18n-aria-label": "topics"
23967
+ title: t("back"),
23968
+ "aria-label": t("back"),
23969
+ "data-i18n-title": "back",
23970
+ "data-i18n-aria-label": "back"
23946
23971
  },
23947
23972
  [[
23948
23973
  "span",
@@ -23950,8 +23975,8 @@ function build_ui$6(gobj) {
23950
23975
  [yui_toolbar_icon("yi-arrow-left")]
23951
23976
  ], [
23952
23977
  "span",
23953
- { i18n: "topics" },
23954
- "topics"
23978
+ { i18n: "back" },
23979
+ "back"
23955
23980
  ]],
23956
23981
  { click: (evt) => {
23957
23982
  evt.stopPropagation();
@@ -25600,9 +25625,27 @@ function ac_set_landing_view(gobj, event, kw, src) {
25600
25625
  return 0;
25601
25626
  }
25602
25627
  /************************************************************
25603
- * Back from a topic to the cards-landing grid (the section index).
25628
+ * Back from a topic to WHERE THE READER WAS.
25629
+ *
25630
+ * Browser Back and this button must land on the same place, or the
25631
+ * reader cannot tell which one to trust (2026-10-10). The button went to
25632
+ * the landing whatever came before it, so "linked records" from
25633
+ * `device_types` opened `devices`, and the arrow then showed the cards
25634
+ * instead of `device_types`, where Back went.
25635
+ *
25636
+ * So it asks the shell for the last route outside the topic on screen
25637
+ * (yui_shell_last_route_outside): the previous topic, the landing, or
25638
+ * the view the reader came from. With none -- the page landed on this
25639
+ * topic -- it goes to the landing, as before.
25604
25640
  ************************************************************/
25605
25641
  function ac_back_to_topics(gobj, event, kw, src) {
25642
+ let shell = yui_shell_of(gobj);
25643
+ let here = shell ? gobj_read_attr(shell, "current_route") || "" : "";
25644
+ let came_from = here ? yui_shell_last_route_outside(shell, here) : "";
25645
+ if (came_from) {
25646
+ yui_shell_navigate(shell, came_from, { push: true });
25647
+ return 0;
25648
+ }
25606
25649
  let routes = gobj_read_attr(gobj, "landing_routes");
25607
25650
  let href = is_object(routes) ? routes[gobj.priv._landing_view] : null;
25608
25651
  if (href && typeof window !== "undefined") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.26.2",
3
+ "version": "7.26.3",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -69,6 +69,7 @@ import {
69
69
  yui_shell_set_sub_routes,
70
70
  yui_shell_navigate,
71
71
  yui_shell_last_route_under,
72
+ yui_shell_last_route_outside,
72
73
  } from "./c_yui_shell.js";
73
74
  import {nodes_answer} from "./nodes_answer.js";
74
75
  import {yui_toolbar_icon} from "./yui_toolbar.js";
@@ -367,13 +368,15 @@ function build_ui(gobj)
367
368
  * graph's toolbar has many more, so it keeps
368
369
  * is-hidden-mobile. */
369
370
 
370
- /* Back to the topic-cards grid (cards-landing mode only);
371
- * hidden until a topic is open. */
371
+ /* Back to where the reader was (cards-landing mode only);
372
+ * hidden until a topic is open. It is 'back' and not
373
+ * 'topics' because that is where it goes: the previous
374
+ * topic, the landing, or the view the reader came from. */
372
375
  ['button', {class: 'button TREEDB_TOPICS_BACK is-hidden',
373
- title: t('topics'), 'aria-label': t('topics'),
374
- 'data-i18n-title': 'topics', 'data-i18n-aria-label': 'topics'}, [
376
+ title: t('back'), 'aria-label': t('back'),
377
+ 'data-i18n-title': 'back', 'data-i18n-aria-label': 'back'}, [
375
378
  ['span', {class: 'icon'}, [yui_toolbar_icon('yi-arrow-left')]],
376
- ['span', {i18n: 'topics'}, 'topics']
379
+ ['span', {i18n: 'back'}, 'back']
377
380
  ], {
378
381
  click: (evt) => {
379
382
  evt.stopPropagation();
@@ -2749,10 +2752,29 @@ function ac_set_landing_view(gobj, event, kw, src)
2749
2752
  }
2750
2753
 
2751
2754
  /************************************************************
2752
- * Back from a topic to the cards-landing grid (the section index).
2755
+ * Back from a topic to WHERE THE READER WAS.
2756
+ *
2757
+ * Browser Back and this button must land on the same place, or the
2758
+ * reader cannot tell which one to trust (2026-10-10). The button went to
2759
+ * the landing whatever came before it, so "linked records" from
2760
+ * `device_types` opened `devices`, and the arrow then showed the cards
2761
+ * instead of `device_types`, where Back went.
2762
+ *
2763
+ * So it asks the shell for the last route outside the topic on screen
2764
+ * (yui_shell_last_route_outside): the previous topic, the landing, or
2765
+ * the view the reader came from. With none -- the page landed on this
2766
+ * topic -- it goes to the landing, as before.
2753
2767
  ************************************************************/
2754
2768
  function ac_back_to_topics(gobj, event, kw, src)
2755
2769
  {
2770
+ let shell = yui_shell_of(gobj);
2771
+ let here = shell ? (gobj_read_attr(shell, "current_route") || "") : "";
2772
+ let came_from = here ? yui_shell_last_route_outside(shell, here) : "";
2773
+ if(came_from) {
2774
+ yui_shell_navigate(shell, came_from, {push: true});
2775
+ return 0;
2776
+ }
2777
+
2756
2778
  /* With host routes the landing is a POSITION, so Back GOES there, the
2757
2779
  * way the toggle does, and the route drives the switch.
2758
2780
  *