@yuneta/gobj-ui 7.26.3 → 7.26.5

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,27 +2699,29 @@ 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) {
2702
+ * The route the reader was on BEFORE this one: the most recent
2703
+ * visited route that is not the current one, or "" when there is
2704
+ * none (the page landed here and has not moved).
2705
+ *
2706
+ * It is what a view's own "←" must use, because the rule is that it
2707
+ * lands where browser Back lands (2026-10-10): two controls that say
2708
+ * "back" and go to different places leave the reader not knowing
2709
+ * which one to trust. A button that names a fixed route (the landing,
2710
+ * a summary) agrees with Back only when the reader came from there;
2711
+ * one that skips a subtree (yui_shell_last_route_outside()) disagrees
2712
+ * as soon as the reader moved inside it -- from one record to the
2713
+ * next, or up a breadcrumb.
2714
+ *
2715
+ * The caller navigates there itself, as a push, and falls back to a
2716
+ * fixed route of its own on "".
2717
+ ************************************************************/
2718
+ function yui_shell_previous_route(shell_gobj) {
2718
2719
  let priv = shell_gobj && shell_gobj.priv;
2719
- if (!priv || !(0, _yuneta_gobj_js.is_array)(priv.route_mru) || !route) return "";
2720
+ if (!priv || !(0, _yuneta_gobj_js.is_array)(priv.route_mru)) return "";
2721
+ let here = (0, _yuneta_gobj_js.gobj_read_attr)(shell_gobj, "current_route") || "";
2720
2722
  for (let i = priv.route_mru.length - 1; i >= 0; i--) {
2721
2723
  let r = priv.route_mru[i];
2722
- if (r !== route && r.indexOf(route + "/") !== 0) return r;
2724
+ if (r !== here) return r;
2723
2725
  }
2724
2726
  return "";
2725
2727
  }
@@ -25638,15 +25640,14 @@ function ac_set_landing_view(gobj, event, kw, src) {
25638
25640
  * `device_types` opened `devices`, and the arrow then showed the cards
25639
25641
  * instead of `device_types`, where Back went.
25640
25642
  *
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
25643
+ * So it asks the shell for the route before this one
25644
+ * (yui_shell_previous_route): the previous topic, the landing, or the
25645
+ * view the reader came from. With none -- the page landed on this
25644
25646
  * topic -- it goes to the landing, as before.
25645
25647
  ************************************************************/
25646
- function ac_back_to_topics(gobj, event, kw, src) {
25648
+ function ac_back_to_topics$1(gobj, event, kw, src) {
25647
25649
  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
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
25650
25651
  if (came_from) {
25651
25652
  yui_shell_navigate(shell, came_from, { push: true });
25652
25653
  return 0;
@@ -26257,7 +26258,7 @@ function create_gclass$6(gclass_name) {
26257
26258
  ],
26258
26259
  [
26259
26260
  "EV_BACK_TO_TOPICS",
26260
- ac_back_to_topics,
26261
+ ac_back_to_topics$1,
26261
26262
  null
26262
26263
  ],
26263
26264
  [
@@ -68445,10 +68446,15 @@ function make_toolbar(gobj) {
68445
68446
  return $toolbar_header;
68446
68447
  }
68447
68448
  /************************************************************
68448
- * "← topics": a real hash link back to the topics grid (host-supplied
68449
- * `back_route`), shown only when set. Lets a graph reached from a topic
68450
- * card's graph icon return to the cards landing — symmetric with the
68451
- * topics view's own back button. Absent (e.g. wattyzer) ⇒ no button.
68449
+ * "← back": shown only when the host supplies `back_route`. Absent
68450
+ * (e.g. wattyzer) ⇒ no button.
68451
+ *
68452
+ * It goes where browser Back goes (EV_BACK_TO_TOPICS): the route the
68453
+ * reader was on before, and `back_route` only when there is none. It
68454
+ * used to go to `back_route` -- the topics grid -- whatever came before,
68455
+ * so a graph opened from one topic sent the reader to the cards while
68456
+ * Back returned to that topic. The `href` stays `back_route`: a real
68457
+ * link, for a middle click or a copied address.
68452
68458
  *
68453
68459
  * It is deliberately NOT a toolbar item: yui_toolbar() lays its items in
68454
68460
  * a horizontally SCROLLING container, and this is the only control here
@@ -68465,10 +68471,10 @@ function make_back_to_topics(gobj) {
68465
68471
  {
68466
68472
  class: "GRAPH_BACK_TOPICS button ml-1 mr-1 is-flex-shrink-0",
68467
68473
  href: back_route,
68468
- title: (0, i18next.t)("topics"),
68469
- "aria-label": (0, i18next.t)("topics"),
68470
- "data-i18n-title": "topics",
68471
- "data-i18n-aria-label": "topics"
68474
+ title: (0, i18next.t)("back"),
68475
+ "aria-label": (0, i18next.t)("back"),
68476
+ "data-i18n-title": "back",
68477
+ "data-i18n-aria-label": "back"
68472
68478
  },
68473
68479
  [[
68474
68480
  "span",
@@ -68479,10 +68485,14 @@ function make_back_to_topics(gobj) {
68479
68485
  {
68480
68486
  class: "is-hidden-mobile",
68481
68487
  style: "padding-left:5px;",
68482
- i18n: "topics"
68488
+ i18n: "back"
68483
68489
  },
68484
- "topics"
68485
- ]]
68490
+ "back"
68491
+ ]],
68492
+ { click: (evt) => {
68493
+ evt.preventDefault();
68494
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_BACK_TO_TOPICS", {}, gobj);
68495
+ } }
68486
68496
  ]);
68487
68497
  (0, _yuneta_gobj_js.refresh_language)($back, i18next.t);
68488
68498
  return $back;
@@ -69997,6 +70007,25 @@ function ac_set_focus_topic(gobj, event, kw, src) {
69997
70007
  return 0;
69998
70008
  }
69999
70009
  /************************************************************
70010
+ * "← back": to the route the reader was on before, as browser Back,
70011
+ * and to `back_route` when there is none (the page landed here).
70012
+ ************************************************************/
70013
+ function ac_back_to_topics(gobj, event, kw, src) {
70014
+ let shell = yui_shell_of(gobj);
70015
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
70016
+ if (came_from) {
70017
+ yui_shell_navigate(shell, came_from, { push: true });
70018
+ return 0;
70019
+ }
70020
+ let back_route = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "back_route") || "";
70021
+ if (!back_route) {
70022
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: back asked with no back_route`);
70023
+ return -1;
70024
+ }
70025
+ window.location.hash = back_route;
70026
+ return 0;
70027
+ }
70028
+ /************************************************************
70000
70029
  * Parent (routing) inform us that we go showing
70001
70030
  *
70002
70031
  * {
@@ -70226,6 +70255,11 @@ function create_gclass$3(gclass_name) {
70226
70255
  ac_show$2,
70227
70256
  null
70228
70257
  ],
70258
+ [
70259
+ "EV_BACK_TO_TOPICS",
70260
+ ac_back_to_topics,
70261
+ null
70262
+ ],
70229
70263
  [
70230
70264
  "EV_HIDE",
70231
70265
  ac_hide$1,
@@ -70284,6 +70318,7 @@ function create_gclass$3(gclass_name) {
70284
70318
  ["EV_OPERATION_MODE_CHANGED", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT | _yuneta_gobj_js.event_flag_t.EVF_NO_WARN_SUBS],
70285
70319
  ["EV_RECORD_WRITTEN", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT | _yuneta_gobj_js.event_flag_t.EVF_NO_WARN_SUBS],
70286
70320
  ["EV_SHOW", 0],
70321
+ ["EV_BACK_TO_TOPICS", 0],
70287
70322
  ["EV_HIDE", 0],
70288
70323
  ["EV_LANGUAGE_CHANGED", 0],
70289
70324
  ["EV_TRANSPORT_STATE", 0]
@@ -76259,8 +76294,29 @@ function ac_select_topic(gobj, event, kw, src) {
76259
76294
  go(gobj, gobj.priv.treedb_id, kw.topic, false, true);
76260
76295
  return reload_after_move(gobj);
76261
76296
  }
76297
+ /***************************************************************
76298
+ * «←»: where browser Back goes, the route before this one.
76299
+ *
76300
+ * It went UP a level (columns -> topics -> treedbs) whatever came
76301
+ * before, and Back undoes the last move: after two topics opened from
76302
+ * the diagram, Back returned to the first one and the arrow to the
76303
+ * treedb (2026-10-10). The rule is that both land on the same place.
76304
+ *
76305
+ * The exception to "this view navigates nothing itself" is this one
76306
+ * control, like the topics view's arrow: it asks the shell, which is
76307
+ * what remembers. Only with a route of its own: mounted without one
76308
+ * (in a window), the route before is the APP's, behind the editor, and
76309
+ * the arrow keeps going up a level. Up a level too when the page has
76310
+ * not moved.
76311
+ ***************************************************************/
76262
76312
  function ac_back(gobj, event, kw, src) {
76263
76313
  let priv = gobj.priv;
76314
+ let shell = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "base_route") ? yui_shell_of(gobj) : null;
76315
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
76316
+ if (came_from) {
76317
+ yui_shell_navigate(shell, came_from, { push: true });
76318
+ return 0;
76319
+ }
76264
76320
  if (priv.diagram || priv.topic_name) go(gobj, priv.treedb_id, "", false, true);
76265
76321
  else go(gobj, "", "", false, true);
76266
76322
  return reload_after_move(gobj);
@@ -2694,27 +2694,29 @@ 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) {
2697
+ * The route the reader was on BEFORE this one: the most recent
2698
+ * visited route that is not the current one, or "" when there is
2699
+ * none (the page landed here and has not moved).
2700
+ *
2701
+ * It is what a view's own "←" must use, because the rule is that it
2702
+ * lands where browser Back lands (2026-10-10): two controls that say
2703
+ * "back" and go to different places leave the reader not knowing
2704
+ * which one to trust. A button that names a fixed route (the landing,
2705
+ * a summary) agrees with Back only when the reader came from there;
2706
+ * one that skips a subtree (yui_shell_last_route_outside()) disagrees
2707
+ * as soon as the reader moved inside it -- from one record to the
2708
+ * next, or up a breadcrumb.
2709
+ *
2710
+ * The caller navigates there itself, as a push, and falls back to a
2711
+ * fixed route of its own on "".
2712
+ ************************************************************/
2713
+ function yui_shell_previous_route(shell_gobj) {
2713
2714
  let priv = shell_gobj && shell_gobj.priv;
2714
- if (!priv || !is_array(priv.route_mru) || !route) return "";
2715
+ if (!priv || !is_array(priv.route_mru)) return "";
2716
+ let here = gobj_read_attr(shell_gobj, "current_route") || "";
2715
2717
  for (let i = priv.route_mru.length - 1; i >= 0; i--) {
2716
2718
  let r = priv.route_mru[i];
2717
- if (r !== route && r.indexOf(route + "/") !== 0) return r;
2719
+ if (r !== here) return r;
2718
2720
  }
2719
2721
  return "";
2720
2722
  }
@@ -25633,15 +25635,14 @@ function ac_set_landing_view(gobj, event, kw, src) {
25633
25635
  * `device_types` opened `devices`, and the arrow then showed the cards
25634
25636
  * instead of `device_types`, where Back went.
25635
25637
  *
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
25638
+ * So it asks the shell for the route before this one
25639
+ * (yui_shell_previous_route): the previous topic, the landing, or the
25640
+ * view the reader came from. With none -- the page landed on this
25639
25641
  * topic -- it goes to the landing, as before.
25640
25642
  ************************************************************/
25641
- function ac_back_to_topics(gobj, event, kw, src) {
25643
+ function ac_back_to_topics$1(gobj, event, kw, src) {
25642
25644
  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
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
25645
25646
  if (came_from) {
25646
25647
  yui_shell_navigate(shell, came_from, { push: true });
25647
25648
  return 0;
@@ -26252,7 +26253,7 @@ function create_gclass$6(gclass_name) {
26252
26253
  ],
26253
26254
  [
26254
26255
  "EV_BACK_TO_TOPICS",
26255
- ac_back_to_topics,
26256
+ ac_back_to_topics$1,
26256
26257
  null
26257
26258
  ],
26258
26259
  [
@@ -68440,10 +68441,15 @@ function make_toolbar(gobj) {
68440
68441
  return $toolbar_header;
68441
68442
  }
68442
68443
  /************************************************************
68443
- * "← topics": a real hash link back to the topics grid (host-supplied
68444
- * `back_route`), shown only when set. Lets a graph reached from a topic
68445
- * card's graph icon return to the cards landing — symmetric with the
68446
- * topics view's own back button. Absent (e.g. wattyzer) ⇒ no button.
68444
+ * "← back": shown only when the host supplies `back_route`. Absent
68445
+ * (e.g. wattyzer) ⇒ no button.
68446
+ *
68447
+ * It goes where browser Back goes (EV_BACK_TO_TOPICS): the route the
68448
+ * reader was on before, and `back_route` only when there is none. It
68449
+ * used to go to `back_route` -- the topics grid -- whatever came before,
68450
+ * so a graph opened from one topic sent the reader to the cards while
68451
+ * Back returned to that topic. The `href` stays `back_route`: a real
68452
+ * link, for a middle click or a copied address.
68447
68453
  *
68448
68454
  * It is deliberately NOT a toolbar item: yui_toolbar() lays its items in
68449
68455
  * a horizontally SCROLLING container, and this is the only control here
@@ -68460,10 +68466,10 @@ function make_back_to_topics(gobj) {
68460
68466
  {
68461
68467
  class: "GRAPH_BACK_TOPICS button ml-1 mr-1 is-flex-shrink-0",
68462
68468
  href: back_route,
68463
- title: t("topics"),
68464
- "aria-label": t("topics"),
68465
- "data-i18n-title": "topics",
68466
- "data-i18n-aria-label": "topics"
68469
+ title: t("back"),
68470
+ "aria-label": t("back"),
68471
+ "data-i18n-title": "back",
68472
+ "data-i18n-aria-label": "back"
68467
68473
  },
68468
68474
  [[
68469
68475
  "span",
@@ -68474,10 +68480,14 @@ function make_back_to_topics(gobj) {
68474
68480
  {
68475
68481
  class: "is-hidden-mobile",
68476
68482
  style: "padding-left:5px;",
68477
- i18n: "topics"
68483
+ i18n: "back"
68478
68484
  },
68479
- "topics"
68480
- ]]
68485
+ "back"
68486
+ ]],
68487
+ { click: (evt) => {
68488
+ evt.preventDefault();
68489
+ gobj_send_event(gobj, "EV_BACK_TO_TOPICS", {}, gobj);
68490
+ } }
68481
68491
  ]);
68482
68492
  refresh_language($back, t);
68483
68493
  return $back;
@@ -69992,6 +70002,25 @@ function ac_set_focus_topic(gobj, event, kw, src) {
69992
70002
  return 0;
69993
70003
  }
69994
70004
  /************************************************************
70005
+ * "← back": to the route the reader was on before, as browser Back,
70006
+ * and to `back_route` when there is none (the page landed here).
70007
+ ************************************************************/
70008
+ function ac_back_to_topics(gobj, event, kw, src) {
70009
+ let shell = yui_shell_of(gobj);
70010
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
70011
+ if (came_from) {
70012
+ yui_shell_navigate(shell, came_from, { push: true });
70013
+ return 0;
70014
+ }
70015
+ let back_route = gobj_read_attr(gobj, "back_route") || "";
70016
+ if (!back_route) {
70017
+ log_error(`${gobj_short_name(gobj)}: back asked with no back_route`);
70018
+ return -1;
70019
+ }
70020
+ window.location.hash = back_route;
70021
+ return 0;
70022
+ }
70023
+ /************************************************************
69995
70024
  * Parent (routing) inform us that we go showing
69996
70025
  *
69997
70026
  * {
@@ -70221,6 +70250,11 @@ function create_gclass$3(gclass_name) {
70221
70250
  ac_show$2,
70222
70251
  null
70223
70252
  ],
70253
+ [
70254
+ "EV_BACK_TO_TOPICS",
70255
+ ac_back_to_topics,
70256
+ null
70257
+ ],
70224
70258
  [
70225
70259
  "EV_HIDE",
70226
70260
  ac_hide$1,
@@ -70279,6 +70313,7 @@ function create_gclass$3(gclass_name) {
70279
70313
  ["EV_OPERATION_MODE_CHANGED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
70280
70314
  ["EV_RECORD_WRITTEN", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
70281
70315
  ["EV_SHOW", 0],
70316
+ ["EV_BACK_TO_TOPICS", 0],
70282
70317
  ["EV_HIDE", 0],
70283
70318
  ["EV_LANGUAGE_CHANGED", 0],
70284
70319
  ["EV_TRANSPORT_STATE", 0]
@@ -76254,8 +76289,29 @@ function ac_select_topic(gobj, event, kw, src) {
76254
76289
  go(gobj, gobj.priv.treedb_id, kw.topic, false, true);
76255
76290
  return reload_after_move(gobj);
76256
76291
  }
76292
+ /***************************************************************
76293
+ * «←»: where browser Back goes, the route before this one.
76294
+ *
76295
+ * It went UP a level (columns -> topics -> treedbs) whatever came
76296
+ * before, and Back undoes the last move: after two topics opened from
76297
+ * the diagram, Back returned to the first one and the arrow to the
76298
+ * treedb (2026-10-10). The rule is that both land on the same place.
76299
+ *
76300
+ * The exception to "this view navigates nothing itself" is this one
76301
+ * control, like the topics view's arrow: it asks the shell, which is
76302
+ * what remembers. Only with a route of its own: mounted without one
76303
+ * (in a window), the route before is the APP's, behind the editor, and
76304
+ * the arrow keeps going up a level. Up a level too when the page has
76305
+ * not moved.
76306
+ ***************************************************************/
76257
76307
  function ac_back(gobj, event, kw, src) {
76258
76308
  let priv = gobj.priv;
76309
+ let shell = gobj_read_attr(gobj, "base_route") ? yui_shell_of(gobj) : null;
76310
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
76311
+ if (came_from) {
76312
+ yui_shell_navigate(shell, came_from, { push: true });
76313
+ return 0;
76314
+ }
76259
76315
  if (priv.diagram || priv.topic_name) go(gobj, priv.treedb_id, "", false, true);
76260
76316
  else go(gobj, "", "", false, true);
76261
76317
  return reload_after_move(gobj);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.26.3",
3
+ "version": "7.26.5",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -149,7 +149,7 @@ import {grouped_flags, toggle_flag} from "./schema_flags.js";
149
149
  import {write_command, write_options} from "./schema_write_options.js";
150
150
  import {COL_TYPES} from "./schema_validate.js";
151
151
 
152
- import {yui_shell_of} from "./c_yui_shell.js";
152
+ import {yui_shell_of, yui_shell_navigate, yui_shell_previous_route} from "./c_yui_shell.js";
153
153
  import {
154
154
  yui_shell_show_modal,
155
155
  yui_shell_show_error,
@@ -3830,10 +3830,32 @@ function ac_select_topic(gobj, event, kw, src)
3830
3830
  return reload_after_move(gobj);
3831
3831
  }
3832
3832
 
3833
+ /***************************************************************
3834
+ * «←»: where browser Back goes, the route before this one.
3835
+ *
3836
+ * It went UP a level (columns -> topics -> treedbs) whatever came
3837
+ * before, and Back undoes the last move: after two topics opened from
3838
+ * the diagram, Back returned to the first one and the arrow to the
3839
+ * treedb (2026-10-10). The rule is that both land on the same place.
3840
+ *
3841
+ * The exception to "this view navigates nothing itself" is this one
3842
+ * control, like the topics view's arrow: it asks the shell, which is
3843
+ * what remembers. Only with a route of its own: mounted without one
3844
+ * (in a window), the route before is the APP's, behind the editor, and
3845
+ * the arrow keeps going up a level. Up a level too when the page has
3846
+ * not moved.
3847
+ ***************************************************************/
3833
3848
  function ac_back(gobj, event, kw, src)
3834
3849
  {
3835
3850
  let priv = gobj.priv;
3836
3851
 
3852
+ let shell = gobj_read_attr(gobj, "base_route") ? yui_shell_of(gobj) : null;
3853
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
3854
+ if(came_from) {
3855
+ yui_shell_navigate(shell, came_from, {push: true});
3856
+ return 0;
3857
+ }
3858
+
3837
3859
  if(priv.diagram || priv.topic_name) {
3838
3860
  go(gobj, priv.treedb_id, "", false, true);
3839
3861
  } else {
@@ -3307,6 +3307,39 @@ function yui_shell_last_route_outside(shell_gobj, route)
3307
3307
  return "";
3308
3308
  }
3309
3309
 
3310
+ /************************************************************
3311
+ * The route the reader was on BEFORE this one: the most recent
3312
+ * visited route that is not the current one, or "" when there is
3313
+ * none (the page landed here and has not moved).
3314
+ *
3315
+ * It is what a view's own "←" must use, because the rule is that it
3316
+ * lands where browser Back lands (2026-10-10): two controls that say
3317
+ * "back" and go to different places leave the reader not knowing
3318
+ * which one to trust. A button that names a fixed route (the landing,
3319
+ * a summary) agrees with Back only when the reader came from there;
3320
+ * one that skips a subtree (yui_shell_last_route_outside()) disagrees
3321
+ * as soon as the reader moved inside it -- from one record to the
3322
+ * next, or up a breadcrumb.
3323
+ *
3324
+ * The caller navigates there itself, as a push, and falls back to a
3325
+ * fixed route of its own on "".
3326
+ ************************************************************/
3327
+ function yui_shell_previous_route(shell_gobj)
3328
+ {
3329
+ let priv = shell_gobj && shell_gobj.priv;
3330
+ if(!priv || !is_array(priv.route_mru)) {
3331
+ return "";
3332
+ }
3333
+ let here = gobj_read_attr(shell_gobj, "current_route") || "";
3334
+ for(let i = priv.route_mru.length - 1; i >= 0; i--) {
3335
+ let r = priv.route_mru[i];
3336
+ if(r !== here) {
3337
+ return r;
3338
+ }
3339
+ }
3340
+ return "";
3341
+ }
3342
+
3310
3343
  /************************************************************
3311
3344
  * Resolve the shell that governs `gobj`: the nearest
3312
3345
  * C_YUI_SHELL ancestor, else the last shell created on the
@@ -3748,6 +3781,7 @@ export {
3748
3781
  yui_shell_navigate,
3749
3782
  yui_shell_last_route_under,
3750
3783
  yui_shell_last_route_outside,
3784
+ yui_shell_previous_route,
3751
3785
  yui_shell_nav_map,
3752
3786
  yui_shell_set_sub_routes,
3753
3787
  yui_shell_register_event_handler,
@@ -92,7 +92,8 @@ import {
92
92
  set_pressed_state,
93
93
  } from "./lib_graph.js";
94
94
  import {yui_shell_show_error, yui_shell_show_modal, yui_shell_popup_layer} from "./shell_modals.js";
95
- import {yui_shell_of, yui_shell_set_sub_routes} from "./c_yui_shell.js";
95
+ import {yui_shell_of, yui_shell_set_sub_routes, yui_shell_navigate, yui_shell_previous_route}
96
+ from "./c_yui_shell.js";
96
97
 
97
98
  import {t} from "i18next";
98
99
 
@@ -1104,10 +1105,15 @@ function make_toolbar(gobj)
1104
1105
  }
1105
1106
 
1106
1107
  /************************************************************
1107
- * "← topics": a real hash link back to the topics grid (host-supplied
1108
- * `back_route`), shown only when set. Lets a graph reached from a topic
1109
- * card's graph icon return to the cards landing — symmetric with the
1110
- * topics view's own back button. Absent (e.g. wattyzer) ⇒ no button.
1108
+ * "← back": shown only when the host supplies `back_route`. Absent
1109
+ * (e.g. wattyzer) ⇒ no button.
1110
+ *
1111
+ * It goes where browser Back goes (EV_BACK_TO_TOPICS): the route the
1112
+ * reader was on before, and `back_route` only when there is none. It
1113
+ * used to go to `back_route` -- the topics grid -- whatever came before,
1114
+ * so a graph opened from one topic sent the reader to the cards while
1115
+ * Back returned to that topic. The `href` stays `back_route`: a real
1116
+ * link, for a middle click or a copied address.
1111
1117
  *
1112
1118
  * It is deliberately NOT a toolbar item: yui_toolbar() lays its items in
1113
1119
  * a horizontally SCROLLING container, and this is the only control here
@@ -1126,12 +1132,17 @@ function make_back_to_topics(gobj)
1126
1132
  let $back = createElement2(
1127
1133
  ['a', {class: 'GRAPH_BACK_TOPICS button ml-1 mr-1 is-flex-shrink-0',
1128
1134
  href: back_route,
1129
- title: t('topics'), 'aria-label': t('topics'),
1130
- 'data-i18n-title': 'topics', 'data-i18n-aria-label': 'topics'}, [
1135
+ title: t('back'), 'aria-label': t('back'),
1136
+ 'data-i18n-title': 'back', 'data-i18n-aria-label': 'back'}, [
1131
1137
  ['span', {class: 'icon'}, [['i', {class: 'yi-arrow-left'}]]],
1132
1138
  ['span', {class: 'is-hidden-mobile', style: 'padding-left:5px;',
1133
- i18n: 'topics'}, 'topics']
1134
- ]]
1139
+ i18n: 'back'}, 'back']
1140
+ ], {
1141
+ click: (evt) => {
1142
+ evt.preventDefault();
1143
+ gobj_send_event(gobj, "EV_BACK_TO_TOPICS", {}, gobj);
1144
+ }
1145
+ }]
1135
1146
  );
1136
1147
  refresh_language($back, t);
1137
1148
 
@@ -3638,6 +3649,27 @@ function ac_set_focus_topic(gobj, event, kw, src)
3638
3649
  return 0;
3639
3650
  }
3640
3651
 
3652
+ /************************************************************
3653
+ * "← back": to the route the reader was on before, as browser Back,
3654
+ * and to `back_route` when there is none (the page landed here).
3655
+ ************************************************************/
3656
+ function ac_back_to_topics(gobj, event, kw, src)
3657
+ {
3658
+ let shell = yui_shell_of(gobj);
3659
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
3660
+ if(came_from) {
3661
+ yui_shell_navigate(shell, came_from, {push: true});
3662
+ return 0;
3663
+ }
3664
+ let back_route = gobj_read_attr(gobj, "back_route") || "";
3665
+ if(!back_route) {
3666
+ log_error(`${gobj_short_name(gobj)}: back asked with no back_route`);
3667
+ return -1;
3668
+ }
3669
+ window.location.hash = back_route;
3670
+ return 0;
3671
+ }
3672
+
3641
3673
  /************************************************************
3642
3674
  * Parent (routing) inform us that we go showing
3643
3675
  *
@@ -3737,6 +3769,7 @@ function create_gclass(gclass_name)
3737
3769
  ["EV_LEGEND_STATE", ac_legend_state, null],
3738
3770
  ["EV_FIND_RESULT", ac_find_result, null],
3739
3771
  ["EV_SHOW", ac_show, null],
3772
+ ["EV_BACK_TO_TOPICS", ac_back_to_topics, null],
3740
3773
  ["EV_HIDE", ac_hide, null],
3741
3774
  ["EV_TRANSPORT_STATE", ac_transport_state, null],
3742
3775
  ["EV_LANGUAGE_CHANGED", ac_language_changed, null],
@@ -3791,6 +3824,7 @@ function create_gclass(gclass_name)
3791
3824
  ["EV_RECORD_WRITTEN",
3792
3825
  event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
3793
3826
  ["EV_SHOW", 0],
3827
+ ["EV_BACK_TO_TOPICS", 0],
3794
3828
  ["EV_HIDE", 0],
3795
3829
  ["EV_LANGUAGE_CHANGED", 0],
3796
3830
  ["EV_TRANSPORT_STATE", 0],
@@ -69,7 +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
+ yui_shell_previous_route,
73
73
  } from "./c_yui_shell.js";
74
74
  import {nodes_answer} from "./nodes_answer.js";
75
75
  import {yui_toolbar_icon} from "./yui_toolbar.js";
@@ -2760,16 +2760,15 @@ function ac_set_landing_view(gobj, event, kw, src)
2760
2760
  * `device_types` opened `devices`, and the arrow then showed the cards
2761
2761
  * instead of `device_types`, where Back went.
2762
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
2763
+ * So it asks the shell for the route before this one
2764
+ * (yui_shell_previous_route): the previous topic, the landing, or the
2765
+ * view the reader came from. With none -- the page landed on this
2766
2766
  * topic -- it goes to the landing, as before.
2767
2767
  ************************************************************/
2768
2768
  function ac_back_to_topics(gobj, event, kw, src)
2769
2769
  {
2770
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) : "";
2771
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
2773
2772
  if(came_from) {
2774
2773
  yui_shell_navigate(shell, came_from, {push: true});
2775
2774
  return 0;
@@ -4,15 +4,31 @@
4
4
  * They read only `priv.route_mru`, so a bare object stands in for
5
5
  * the shell.
6
6
  */
7
- import {describe, it, expect} from "vitest";
7
+ import {describe, it, expect, vi} from "vitest";
8
+
9
+ /* yui_shell_previous_route() reads the shell's `current_route` attr;
10
+ * the stand-in carries it in `attrs`. */
11
+ vi.mock("@yuneta/gobj-js", async (importOriginal) => {
12
+ const orig = await importOriginal();
13
+ return {
14
+ ...orig,
15
+ gobj_read_attr: (gobj, name) => (gobj && gobj.attrs && name in gobj.attrs)?
16
+ gobj.attrs[name]: orig.gobj_read_attr(gobj, name),
17
+ };
18
+ });
19
+
8
20
  import {
9
21
  yui_shell_last_route_under,
10
22
  yui_shell_last_route_outside,
23
+ yui_shell_previous_route,
11
24
  } from "./c_yui_shell.js";
12
25
 
13
- function shell(mru)
26
+ function shell(mru, current)
14
27
  {
15
- return {priv: {route_mru: mru}};
28
+ return {
29
+ priv: {route_mru: mru},
30
+ attrs: {current_route: current === undefined? mru[mru.length - 1] || "": current},
31
+ };
16
32
  }
17
33
 
18
34
  describe("yui_shell_last_route_outside", () => {
@@ -51,3 +67,26 @@ describe("yui_shell_last_route_under", () => {
51
67
  expect(yui_shell_last_route_under(s, "/cards")).toBe("/cards");
52
68
  });
53
69
  });
70
+
71
+ describe("yui_shell_previous_route", () => {
72
+ it("answers the route before the current one, as browser Back does", () => {
73
+ const s = shell(["/topics", "/topics/device_types", "/topics/devices"]);
74
+ expect(yui_shell_previous_route(s)).toBe("/topics/device_types");
75
+ });
76
+
77
+ it("goes back to the previous record, not past it", () => {
78
+ const s = shell(["/map/table", "/detail/E1", "/detail/E2"]);
79
+ expect(yui_shell_previous_route(s)).toBe("/detail/E1");
80
+ });
81
+
82
+ it("goes back DOWN after a breadcrumb took the reader up", () => {
83
+ const s = shell(["/schemas/db", "/schemas/db/users", "/schemas/db/users/cols", "/schemas/db"]);
84
+ expect(yui_shell_previous_route(s)).toBe("/schemas/db/users/cols");
85
+ });
86
+
87
+ it("answers empty when the page has not moved", () => {
88
+ expect(yui_shell_previous_route(shell(["/detail/E1"]))).toBe("");
89
+ expect(yui_shell_previous_route(shell([]))).toBe("");
90
+ expect(yui_shell_previous_route(null)).toBe("");
91
+ });
92
+ });