@yuneta/gobj-ui 7.26.2 → 7.26.4

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,33 @@ function yui_shell_last_route_under(shell_gobj, route) {
2699
2699
  return route;
2700
2700
  }
2701
2701
  /************************************************************
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) {
2719
+ let priv = shell_gobj && shell_gobj.priv;
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") || "";
2722
+ for (let i = priv.route_mru.length - 1; i >= 0; i--) {
2723
+ let r = priv.route_mru[i];
2724
+ if (r !== here) return r;
2725
+ }
2726
+ return "";
2727
+ }
2728
+ /************************************************************
2702
2729
  * Resolve the shell that governs `gobj`: the nearest
2703
2730
  * C_YUI_SHELL ancestor, else the last shell created on the
2704
2731
  * page (apps have exactly one). Null when no shell exists —
@@ -23944,10 +23971,10 @@ function build_ui$6(gobj) {
23944
23971
  "button",
23945
23972
  {
23946
23973
  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"
23974
+ title: (0, i18next.t)("back"),
23975
+ "aria-label": (0, i18next.t)("back"),
23976
+ "data-i18n-title": "back",
23977
+ "data-i18n-aria-label": "back"
23951
23978
  },
23952
23979
  [[
23953
23980
  "span",
@@ -23955,8 +23982,8 @@ function build_ui$6(gobj) {
23955
23982
  [yui_toolbar_icon("yi-arrow-left")]
23956
23983
  ], [
23957
23984
  "span",
23958
- { i18n: "topics" },
23959
- "topics"
23985
+ { i18n: "back" },
23986
+ "back"
23960
23987
  ]],
23961
23988
  { click: (evt) => {
23962
23989
  evt.stopPropagation();
@@ -25605,9 +25632,26 @@ function ac_set_landing_view(gobj, event, kw, src) {
25605
25632
  return 0;
25606
25633
  }
25607
25634
  /************************************************************
25608
- * Back from a topic to the cards-landing grid (the section index).
25635
+ * Back from a topic to WHERE THE READER WAS.
25636
+ *
25637
+ * Browser Back and this button must land on the same place, or the
25638
+ * reader cannot tell which one to trust (2026-10-10). The button went to
25639
+ * the landing whatever came before it, so "linked records" from
25640
+ * `device_types` opened `devices`, and the arrow then showed the cards
25641
+ * instead of `device_types`, where Back went.
25642
+ *
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
25646
+ * topic -- it goes to the landing, as before.
25609
25647
  ************************************************************/
25610
- function ac_back_to_topics(gobj, event, kw, src) {
25648
+ function ac_back_to_topics$1(gobj, event, kw, src) {
25649
+ let shell = yui_shell_of(gobj);
25650
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
25651
+ if (came_from) {
25652
+ yui_shell_navigate(shell, came_from, { push: true });
25653
+ return 0;
25654
+ }
25611
25655
  let routes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "landing_routes");
25612
25656
  let href = (0, _yuneta_gobj_js.is_object)(routes) ? routes[gobj.priv._landing_view] : null;
25613
25657
  if (href && typeof window !== "undefined") {
@@ -26214,7 +26258,7 @@ function create_gclass$6(gclass_name) {
26214
26258
  ],
26215
26259
  [
26216
26260
  "EV_BACK_TO_TOPICS",
26217
- ac_back_to_topics,
26261
+ ac_back_to_topics$1,
26218
26262
  null
26219
26263
  ],
26220
26264
  [
@@ -68402,10 +68446,15 @@ function make_toolbar(gobj) {
68402
68446
  return $toolbar_header;
68403
68447
  }
68404
68448
  /************************************************************
68405
- * "← topics": a real hash link back to the topics grid (host-supplied
68406
- * `back_route`), shown only when set. Lets a graph reached from a topic
68407
- * card's graph icon return to the cards landing — symmetric with the
68408
- * 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.
68409
68458
  *
68410
68459
  * It is deliberately NOT a toolbar item: yui_toolbar() lays its items in
68411
68460
  * a horizontally SCROLLING container, and this is the only control here
@@ -68422,10 +68471,10 @@ function make_back_to_topics(gobj) {
68422
68471
  {
68423
68472
  class: "GRAPH_BACK_TOPICS button ml-1 mr-1 is-flex-shrink-0",
68424
68473
  href: back_route,
68425
- title: (0, i18next.t)("topics"),
68426
- "aria-label": (0, i18next.t)("topics"),
68427
- "data-i18n-title": "topics",
68428
- "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"
68429
68478
  },
68430
68479
  [[
68431
68480
  "span",
@@ -68436,10 +68485,14 @@ function make_back_to_topics(gobj) {
68436
68485
  {
68437
68486
  class: "is-hidden-mobile",
68438
68487
  style: "padding-left:5px;",
68439
- i18n: "topics"
68488
+ i18n: "back"
68440
68489
  },
68441
- "topics"
68442
- ]]
68490
+ "back"
68491
+ ]],
68492
+ { click: (evt) => {
68493
+ evt.preventDefault();
68494
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_BACK_TO_TOPICS", {}, gobj);
68495
+ } }
68443
68496
  ]);
68444
68497
  (0, _yuneta_gobj_js.refresh_language)($back, i18next.t);
68445
68498
  return $back;
@@ -69954,6 +70007,25 @@ function ac_set_focus_topic(gobj, event, kw, src) {
69954
70007
  return 0;
69955
70008
  }
69956
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
+ /************************************************************
69957
70029
  * Parent (routing) inform us that we go showing
69958
70030
  *
69959
70031
  * {
@@ -70183,6 +70255,11 @@ function create_gclass$3(gclass_name) {
70183
70255
  ac_show$2,
70184
70256
  null
70185
70257
  ],
70258
+ [
70259
+ "EV_BACK_TO_TOPICS",
70260
+ ac_back_to_topics,
70261
+ null
70262
+ ],
70186
70263
  [
70187
70264
  "EV_HIDE",
70188
70265
  ac_hide$1,
@@ -70241,6 +70318,7 @@ function create_gclass$3(gclass_name) {
70241
70318
  ["EV_OPERATION_MODE_CHANGED", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT | _yuneta_gobj_js.event_flag_t.EVF_NO_WARN_SUBS],
70242
70319
  ["EV_RECORD_WRITTEN", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT | _yuneta_gobj_js.event_flag_t.EVF_NO_WARN_SUBS],
70243
70320
  ["EV_SHOW", 0],
70321
+ ["EV_BACK_TO_TOPICS", 0],
70244
70322
  ["EV_HIDE", 0],
70245
70323
  ["EV_LANGUAGE_CHANGED", 0],
70246
70324
  ["EV_TRANSPORT_STATE", 0]
@@ -2694,6 +2694,33 @@ function yui_shell_last_route_under(shell_gobj, route) {
2694
2694
  return route;
2695
2695
  }
2696
2696
  /************************************************************
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) {
2714
+ let priv = shell_gobj && shell_gobj.priv;
2715
+ if (!priv || !is_array(priv.route_mru)) return "";
2716
+ let here = gobj_read_attr(shell_gobj, "current_route") || "";
2717
+ for (let i = priv.route_mru.length - 1; i >= 0; i--) {
2718
+ let r = priv.route_mru[i];
2719
+ if (r !== here) return r;
2720
+ }
2721
+ return "";
2722
+ }
2723
+ /************************************************************
2697
2724
  * Resolve the shell that governs `gobj`: the nearest
2698
2725
  * C_YUI_SHELL ancestor, else the last shell created on the
2699
2726
  * page (apps have exactly one). Null when no shell exists —
@@ -23939,10 +23966,10 @@ function build_ui$6(gobj) {
23939
23966
  "button",
23940
23967
  {
23941
23968
  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"
23969
+ title: t("back"),
23970
+ "aria-label": t("back"),
23971
+ "data-i18n-title": "back",
23972
+ "data-i18n-aria-label": "back"
23946
23973
  },
23947
23974
  [[
23948
23975
  "span",
@@ -23950,8 +23977,8 @@ function build_ui$6(gobj) {
23950
23977
  [yui_toolbar_icon("yi-arrow-left")]
23951
23978
  ], [
23952
23979
  "span",
23953
- { i18n: "topics" },
23954
- "topics"
23980
+ { i18n: "back" },
23981
+ "back"
23955
23982
  ]],
23956
23983
  { click: (evt) => {
23957
23984
  evt.stopPropagation();
@@ -25600,9 +25627,26 @@ function ac_set_landing_view(gobj, event, kw, src) {
25600
25627
  return 0;
25601
25628
  }
25602
25629
  /************************************************************
25603
- * Back from a topic to the cards-landing grid (the section index).
25630
+ * Back from a topic to WHERE THE READER WAS.
25631
+ *
25632
+ * Browser Back and this button must land on the same place, or the
25633
+ * reader cannot tell which one to trust (2026-10-10). The button went to
25634
+ * the landing whatever came before it, so "linked records" from
25635
+ * `device_types` opened `devices`, and the arrow then showed the cards
25636
+ * instead of `device_types`, where Back went.
25637
+ *
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
25641
+ * topic -- it goes to the landing, as before.
25604
25642
  ************************************************************/
25605
- function ac_back_to_topics(gobj, event, kw, src) {
25643
+ function ac_back_to_topics$1(gobj, event, kw, src) {
25644
+ let shell = yui_shell_of(gobj);
25645
+ let came_from = shell ? yui_shell_previous_route(shell) : "";
25646
+ if (came_from) {
25647
+ yui_shell_navigate(shell, came_from, { push: true });
25648
+ return 0;
25649
+ }
25606
25650
  let routes = gobj_read_attr(gobj, "landing_routes");
25607
25651
  let href = is_object(routes) ? routes[gobj.priv._landing_view] : null;
25608
25652
  if (href && typeof window !== "undefined") {
@@ -26209,7 +26253,7 @@ function create_gclass$6(gclass_name) {
26209
26253
  ],
26210
26254
  [
26211
26255
  "EV_BACK_TO_TOPICS",
26212
- ac_back_to_topics,
26256
+ ac_back_to_topics$1,
26213
26257
  null
26214
26258
  ],
26215
26259
  [
@@ -68397,10 +68441,15 @@ function make_toolbar(gobj) {
68397
68441
  return $toolbar_header;
68398
68442
  }
68399
68443
  /************************************************************
68400
- * "← topics": a real hash link back to the topics grid (host-supplied
68401
- * `back_route`), shown only when set. Lets a graph reached from a topic
68402
- * card's graph icon return to the cards landing — symmetric with the
68403
- * 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.
68404
68453
  *
68405
68454
  * It is deliberately NOT a toolbar item: yui_toolbar() lays its items in
68406
68455
  * a horizontally SCROLLING container, and this is the only control here
@@ -68417,10 +68466,10 @@ function make_back_to_topics(gobj) {
68417
68466
  {
68418
68467
  class: "GRAPH_BACK_TOPICS button ml-1 mr-1 is-flex-shrink-0",
68419
68468
  href: back_route,
68420
- title: t("topics"),
68421
- "aria-label": t("topics"),
68422
- "data-i18n-title": "topics",
68423
- "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"
68424
68473
  },
68425
68474
  [[
68426
68475
  "span",
@@ -68431,10 +68480,14 @@ function make_back_to_topics(gobj) {
68431
68480
  {
68432
68481
  class: "is-hidden-mobile",
68433
68482
  style: "padding-left:5px;",
68434
- i18n: "topics"
68483
+ i18n: "back"
68435
68484
  },
68436
- "topics"
68437
- ]]
68485
+ "back"
68486
+ ]],
68487
+ { click: (evt) => {
68488
+ evt.preventDefault();
68489
+ gobj_send_event(gobj, "EV_BACK_TO_TOPICS", {}, gobj);
68490
+ } }
68438
68491
  ]);
68439
68492
  refresh_language($back, t);
68440
68493
  return $back;
@@ -69949,6 +70002,25 @@ function ac_set_focus_topic(gobj, event, kw, src) {
69949
70002
  return 0;
69950
70003
  }
69951
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
+ /************************************************************
69952
70024
  * Parent (routing) inform us that we go showing
69953
70025
  *
69954
70026
  * {
@@ -70178,6 +70250,11 @@ function create_gclass$3(gclass_name) {
70178
70250
  ac_show$2,
70179
70251
  null
70180
70252
  ],
70253
+ [
70254
+ "EV_BACK_TO_TOPICS",
70255
+ ac_back_to_topics,
70256
+ null
70257
+ ],
70181
70258
  [
70182
70259
  "EV_HIDE",
70183
70260
  ac_hide$1,
@@ -70236,6 +70313,7 @@ function create_gclass$3(gclass_name) {
70236
70313
  ["EV_OPERATION_MODE_CHANGED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
70237
70314
  ["EV_RECORD_WRITTEN", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
70238
70315
  ["EV_SHOW", 0],
70316
+ ["EV_BACK_TO_TOPICS", 0],
70239
70317
  ["EV_HIDE", 0],
70240
70318
  ["EV_LANGUAGE_CHANGED", 0],
70241
70319
  ["EV_TRANSPORT_STATE", 0]
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.4",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -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,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_previous_route,
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,28 @@ 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 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
+ * 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 came_from = shell ? yui_shell_previous_route(shell) : "";
2772
+ if(came_from) {
2773
+ yui_shell_navigate(shell, came_from, {push: true});
2774
+ return 0;
2775
+ }
2776
+
2756
2777
  /* With host routes the landing is a POSITION, so Back GOES there, the
2757
2778
  * way the toggle does, and the route drives the switch.
2758
2779
  *
@@ -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
+ });