@yuneta/gobj-ui 7.26.41 → 7.26.42

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.
@@ -48,6 +48,7 @@ import {
48
48
  gobj_has_event,
49
49
  gobj_short_name,
50
50
  gobj_is_destroying,
51
+ gobj_post_event,
51
52
  } from "@yuneta/gobj-js";
52
53
 
53
54
  import {
@@ -81,11 +82,15 @@ import {
81
82
  ***************************************************************/
82
83
  const GCLASS_NAME = "C_YUI_SHELL";
83
84
 
84
- /* Last shell created on the page — fallback for yui_shell_of()
85
- * when the caller is not a shell descendant (e.g. a floating
86
- * C_YUI_WINDOW parented to the app gobj). Real apps have exactly
87
- * one shell; tests that create several get the most recent. */
88
- let __last_shell__ = null;
85
+ /* The shells alive on the page, in the order they were built. The
86
+ * LAST one is the fallback of yui_shell_of() when the caller is not
87
+ * a shell descendant (e.g. a floating C_YUI_WINDOW parented to the
88
+ * app gobj). Real apps have exactly one shell; tests that create
89
+ * several get the most recent. A list, not one pointer: with two
90
+ * alive, destroying the last left the fallback EMPTY, and the
91
+ * windows it held went to the body -- above the dialogs of the shell
92
+ * that remained -- up to 7.26.41. They go to that shell now. */
93
+ let __live_shells__ = [];
89
94
 
90
95
  /* The gobjs that keep DOM in a shell's layers without being its
91
96
  * children: a C_YUI_WINDOW parented to the app, the dock of
@@ -146,6 +151,11 @@ let PRIVATE_DATA = {
146
151
  nav_badges: {},
147
152
  /* The live region a changed badge is said in (announce_badge()). */
148
153
  badge_status: null,
154
+ /* What this turn of the loop said in it: [{source, message}], in
155
+ * the order the changes came, and whether the EV_CLOSE_BADGE_NEWS
156
+ * that ends the turn is posted (announce_badge()). */
157
+ badge_news: [],
158
+ badge_news_closing: false,
149
159
  /* Parent item id -> the items yui_shell_set_submenu() put in place:
150
160
  * menu items as much as the declared ones (nav_item_of). */
151
161
  dynamic_items: {},
@@ -274,7 +284,7 @@ function mt_create(gobj)
274
284
  gobj_subscribe_event(gobj, null, {}, subscriber);
275
285
  }
276
286
 
277
- __last_shell__ = gobj;
287
+ __live_shells__.push(gobj);
278
288
 
279
289
  build_ui(gobj);
280
290
 
@@ -634,8 +644,9 @@ function mt_destroy(gobj)
634
644
  * when stop is skipped. */
635
645
  close_toolbar_dropdown(gobj);
636
646
 
637
- if(__last_shell__ === gobj) {
638
- __last_shell__ = null;
647
+ let live_idx = __live_shells__.indexOf(gobj);
648
+ if(live_idx >= 0) {
649
+ __live_shells__.splice(live_idx, 1);
639
650
  }
640
651
 
641
652
  let $container = gobj_read_attr(gobj, "$container");
@@ -649,9 +660,10 @@ function mt_destroy(gobj)
649
660
  * shell, so a logout that destroyed the shell left such a window
650
661
  * alive with its DOM detached, and the next shell never placed it
651
662
  * again -- invisible, and the first click on its menu entry closed
652
- * the invisible one. Told now -- with `__last_shell__` cleared, so
653
- * the place they find is the body, and with the $container still
654
- * readable, so each can tell whether it was inside. */
663
+ * the invisible one. Told now -- with this shell out of
664
+ * `__live_shells__`, so the place they find is the shell that
665
+ * remains (the body when none does), and with the $container
666
+ * still readable, so each can tell whether it was inside. */
655
667
  tell_shell_watchers(gobj);
656
668
 
657
669
  gobj_write_attr(gobj, "$container", null);
@@ -1260,9 +1272,13 @@ function instantiate_menus(gobj, config)
1260
1272
  items: sub.items,
1261
1273
  render: { [zone_id]: render_cfg }
1262
1274
  };
1275
+ /* Named by the entry that opens it, as the nav names
1276
+ * the entry (`name`, else `aria_label`, else id): a
1277
+ * parent with only an `aria_label` gave a navigation
1278
+ * called "navigation" up to 7.26.41. */
1263
1279
  let nav = instantiate_nav_in_zone(
1264
1280
  gobj, submenu_def, sub_menu_id, zone_id, "secondary",
1265
- item.name || ""
1281
+ item.name || item.aria_label || item.id || ""
1266
1282
  );
1267
1283
  /* Hidden until owning primary is active. */
1268
1284
  let $c = gobj_read_attr(nav, "$container");
@@ -1983,16 +1999,21 @@ function build_toolbar_action_item(gobj, it)
1983
1999
  text_node(it.name)]);
1984
2000
  }
1985
2001
 
1986
- let aria_key = it.aria_label || it.name || it.id || "";
1987
- let i18n_aria = it.aria_label || it.name;
2002
+ /* The name of an item: its `aria_label` -- the toolbar's explicit
2003
+ * name, which wins over a visible `name` that is often a symbol
2004
+ * ("ES/EN") --, else its `name`, else its id: a KEY in every case,
2005
+ * translated by the pass that translates the labels and reached by
2006
+ * a language switch, with a title. Up to 7.26.41 an item with
2007
+ * neither was named by its raw id, with no key and no title. */
2008
+ let name_key = it.aria_label || it.name || it.id || "";
1988
2009
  let btn_attrs = {
1989
2010
  class: "navbar-item yui-toolbar-item is-unselectable",
1990
2011
  type: "button",
1991
2012
  "data-toolbar-item-id": it.id || "",
1992
- "aria-label": aria_key
2013
+ "aria-label": name_key
1993
2014
  };
1994
- if(i18n_aria) {
1995
- btn_attrs["data-i18n-aria-label"] = i18n_aria;
2015
+ if(name_key) {
2016
+ btn_attrs["data-i18n-aria-label"] = name_key;
1996
2017
  }
1997
2018
  let action_type = (it.action && it.action.type) || "";
1998
2019
  if(action_type === "dropdown") {
@@ -2001,16 +2022,16 @@ function build_toolbar_action_item(gobj, it)
2001
2022
  }
2002
2023
  /* Hover tooltip: prefer explicit `tooltip`, then `aria_label`
2003
2024
  * (usually the same intent — e.g. "Search (Ctrl+F)"), then the
2004
- * name: every control carries a title. Skip only when all are
2005
- * empty, so we don't emit `title=""` noise.
2025
+ * name, then the id: every control carries a title. Skip only
2026
+ * when all are empty, so we don't emit `title=""` noise.
2006
2027
  * Mirror the value in `data-i18n-title` so refresh_language()
2007
2028
  * can re-translate the tooltip on language switch. */
2008
- let tip = it.tooltip || i18n_aria;
2029
+ let tip = it.tooltip || name_key;
2009
2030
  if(tip) {
2010
2031
  btn_attrs.title = tip;
2011
2032
  btn_attrs["data-i18n-title"] = tip;
2012
2033
  }
2013
- if(badge && !empty_string(aria_key)) {
2034
+ if(badge && !empty_string(name_key)) {
2014
2035
  /* The count is part of its name: inside a <button> the badge is
2015
2036
  * no node of its own for a reader (yui_badge.js). */
2016
2037
  name_control_with_badge(btn_attrs, badge);
@@ -2105,21 +2126,24 @@ function build_toolbar_brand_item(gobj, it)
2105
2126
  function build_toolbar_avatar_item(gobj, it)
2106
2127
  {
2107
2128
  let priv = gobj.priv;
2108
- const aria_key = it.aria_label || it.name || it.id || "user menu";
2109
- const i18n_aria = it.aria_label || it.name || "user menu";
2129
+ /* Named by its `aria_label`, else its `name`, else the library's
2130
+ * own "user menu" -- the KEY its aria-label shows from the start.
2131
+ * Up to 7.26.41 an avatar with neither showed its raw id until a
2132
+ * pass of translation replaced it with that key. */
2133
+ const name_key = it.aria_label || it.name || "user menu";
2110
2134
  let action_type = (it.action && it.action.type) || "";
2111
2135
  let attrs = {
2112
2136
  class: "navbar-item yui-toolbar-item yui-toolbar-avatar is-unselectable",
2113
2137
  type: "button",
2114
2138
  "data-toolbar-item-id": it.id || "",
2115
- "aria-label": aria_key,
2116
- "data-i18n-aria-label": i18n_aria
2139
+ "aria-label": name_key,
2140
+ "data-i18n-aria-label": name_key
2117
2141
  };
2118
2142
  if(action_type === "dropdown") {
2119
2143
  attrs["aria-haspopup"] = "menu";
2120
2144
  attrs["aria-expanded"] = "false";
2121
2145
  }
2122
- let tip = it.tooltip || i18n_aria;
2146
+ let tip = it.tooltip || name_key;
2123
2147
  if(tip) {
2124
2148
  attrs.title = tip;
2125
2149
  attrs["data-i18n-title"] = tip;
@@ -2196,17 +2220,19 @@ function attach_context_action(gobj, $item, it)
2196
2220
  function build_toolbar_connection_item(gobj, it)
2197
2221
  {
2198
2222
  let priv = gobj.priv;
2199
- const aria_key = it.aria_label || it.name || it.id || "backend connection";
2200
- const i18n_aria = it.aria_label || it.name || "backend connection";
2223
+ /* Named as the avatar is: its `aria_label`, else its `name`, else
2224
+ * the library's own "backend connection", the key its aria-label
2225
+ * shows from the start (it was the raw id until a pass). */
2226
+ const name_key = it.aria_label || it.name || "backend connection";
2201
2227
  let attrs = {
2202
2228
  class: "navbar-item yui-toolbar-item yui-toolbar-conn " +
2203
2229
  "is-unselectable is-disconnected",
2204
2230
  type: "button",
2205
2231
  "data-toolbar-item-id": it.id || "",
2206
- "aria-label": aria_key,
2207
- "data-i18n-aria-label": i18n_aria
2232
+ "aria-label": name_key,
2233
+ "data-i18n-aria-label": name_key
2208
2234
  };
2209
- let tip = it.tooltip || i18n_aria;
2235
+ let tip = it.tooltip || name_key;
2210
2236
  if(tip) {
2211
2237
  attrs.title = tip;
2212
2238
  attrs["data-i18n-title"] = tip;
@@ -2372,14 +2398,22 @@ function open_toolbar_dropdown(gobj, item, action, $trigger)
2372
2398
  * The fix is below: when the host has registered a translator
2373
2399
  * (yui_shell_set_translator), re-apply it to the freshly built
2374
2400
  * $panel. Rebuilt per open ⇒ a later language switch is picked
2375
- * up the next time the dropdown opens. */
2376
- const aria_key = item && (item.aria_label || item.name || item.id) || "menu";
2377
- const i18n_aria = (item && (item.aria_label || item.name)) || "menu";
2401
+ * up the next time the dropdown opens.
2402
+ *
2403
+ * The menu is named as its trigger is (build_toolbar_*): its
2404
+ * `aria_label`, else its `name`, else -- an avatar -- the library's
2405
+ * "user menu", else its id; a KEY in every case. Up to 7.26.41 a
2406
+ * menu whose trigger had neither `aria_label` nor `name` was named
2407
+ * by the raw id, and an avatar's said "user" where its button said
2408
+ * "user menu". (A brand that opens a menu, which no app has, names
2409
+ * it by its `aria_label` or its id, not by its wordmark.) */
2410
+ const name_key = (item && (item.aria_label || item.name ||
2411
+ (classify_toolbar_item(item) === "avatar" ? "user menu" : item.id))) || "menu";
2378
2412
  let $panel = createElement2(["div", {
2379
2413
  class: "yui-toolbar-dropdown-panel",
2380
2414
  role: "menu",
2381
- "aria-label": aria_key,
2382
- "data-i18n-aria-label": i18n_aria,
2415
+ "aria-label": name_key,
2416
+ "data-i18n-aria-label": name_key,
2383
2417
  "data-toolbar-dropdown-for": (item && item.id) || ""
2384
2418
  }]);
2385
2419
 
@@ -2578,20 +2612,22 @@ function build_dropdown_row(gobj, sub, idx)
2578
2612
  children.push(["span", {class: "yui-toolbar-dropdown-check"},
2579
2613
  ["i", {class: "yi-check", "aria-hidden": "true"}]]);
2580
2614
 
2581
- let aria_key = sub.aria_label || sub.name || sub.id || "";
2582
- let i18n_aria = sub.aria_label || sub.name;
2615
+ /* Named as a toolbar item is: its `aria_label`, else its `name`,
2616
+ * else its id -- a KEY in every case, with a title (an icon row
2617
+ * without a name was named by its raw id up to 7.26.41). */
2618
+ let name_key = sub.aria_label || sub.name || sub.id || "";
2583
2619
  let attrs = {
2584
2620
  class: "yui-toolbar-dropdown-item" + (sub.selected ? " is-selected" : ""),
2585
2621
  type: "button",
2586
2622
  role: "menuitemradio",
2587
2623
  "aria-checked": sub.selected ? "true" : "false",
2588
2624
  "data-dropdown-item-id": sub.id || "",
2589
- "aria-label": aria_key
2625
+ "aria-label": name_key
2590
2626
  };
2591
- if(i18n_aria) {
2592
- attrs["data-i18n-aria-label"] = i18n_aria;
2593
- attrs.title = i18n_aria;
2594
- attrs["data-i18n-title"] = i18n_aria;
2627
+ if(name_key) {
2628
+ attrs["data-i18n-aria-label"] = name_key;
2629
+ attrs.title = name_key;
2630
+ attrs["data-i18n-title"] = name_key;
2595
2631
  }
2596
2632
  let $btn = createElement2(["button", attrs, children]);
2597
2633
  $btn.addEventListener("click", ev => {
@@ -3338,26 +3374,103 @@ function shell_navs(gobj)
3338
3374
  * `name_key` is the key of the control's name; the phrase is a
3339
3375
  * key of its own, so a language orders and punctuates it its
3340
3376
  * way. Said once: a live region needs no re-translation.
3377
+ *
3378
+ * `source` names the badge ("toolbar:<id>", "nav:<id>"). Every
3379
+ * change of ONE turn of the loop is said in ONE message, a line
3380
+ * of the region each, in the order they came; a badge that moves
3381
+ * twice in the turn says its last count. Up to 7.26.41 each
3382
+ * change replaced the region's text, and a reader hears the
3383
+ * region as it is when the turn is over: of two changes in one
3384
+ * action (a feed that updates the toolbar's count and the menu
3385
+ * entry's, which is what a count is for) only the second was
3386
+ * ever said. The turn is closed by EV_CLOSE_BADGE_NEWS, posted to
3387
+ * the shell by its first change: gobj_post_event() delivers it on
3388
+ * the next turn, through the machine -- a deferral, not a time.
3341
3389
  ************************************************************/
3342
- function announce_badge(gobj, name_key, text)
3390
+ function announce_badge(gobj, name_key, text, source)
3343
3391
  {
3344
3392
  let priv = gobj.priv;
3345
- let $status = priv.badge_status;
3346
- if(!$status) {
3393
+ if(gobj_is_destroying(gobj)) {
3394
+ return; /* its live region goes with it: nobody is left to tell */
3395
+ }
3396
+ if(!priv.badge_status) {
3347
3397
  log_error(`C_YUI_SHELL: no live region to say badge '${name_key}': ${text}`);
3348
3398
  return;
3349
3399
  }
3350
3400
  let message;
3351
3401
  if(typeof priv.translator === "function") {
3352
3402
  const tr = priv.translator;
3353
- message = tr("{{name}}, {{n}}", {name: tr(name_key), n: text});
3403
+ /* Not escaped: i18next escapes an interpolated value for HTML
3404
+ * by default, and the message is a text node -- a name such as
3405
+ * "Événements d'alarme" was read "d&#39;alarme". */
3406
+ message = tr("{{name}}, {{n}}", {
3407
+ name: tr(name_key), n: text, interpolation: {escapeValue: false}
3408
+ });
3354
3409
  } else {
3355
3410
  message = `${name_key}, ${text}`;
3356
3411
  }
3357
- /* Written even when it reads the same: the callers filter what is
3358
- * no news, and a count that went away and came back IS news -- a
3359
- * new text node is a change a reader announces. */
3360
- $status.textContent = message;
3412
+
3413
+ let news = priv.badge_news.find((n) => n.source === source);
3414
+ if(news) {
3415
+ news.message = message;
3416
+ } else {
3417
+ priv.badge_news.push({source: source, message: message});
3418
+ }
3419
+ write_badge_news(gobj);
3420
+
3421
+ if(priv.badge_news_closing) {
3422
+ return;
3423
+ }
3424
+ if(gobj_post_event(gobj, "EV_CLOSE_BADGE_NEWS", {}, gobj) < 0) {
3425
+ /* Error already logged. Nothing will close this turn's message:
3426
+ * it is closed now, and the next change is said on its own. */
3427
+ priv.badge_news = [];
3428
+ return;
3429
+ }
3430
+ priv.badge_news_closing = true;
3431
+ }
3432
+
3433
+ /************************************************************
3434
+ * A badge whose count went away in the turn it changed: what
3435
+ * this turn said of it is no news any more -- the badge shows
3436
+ * nothing -- and is taken out of the message.
3437
+ ************************************************************/
3438
+ function forget_badge_news(gobj, source)
3439
+ {
3440
+ let priv = gobj.priv;
3441
+ let idx = priv.badge_news.findIndex((n) => n.source === source);
3442
+ if(idx < 0) {
3443
+ return;
3444
+ }
3445
+ priv.badge_news.splice(idx, 1);
3446
+ write_badge_news(gobj);
3447
+ }
3448
+
3449
+ /************************************************************
3450
+ * The live region holds the message of this turn: a line per
3451
+ * change, so a reader separates them without a punctuation of
3452
+ * ours, and two controls of one name with one count say it once.
3453
+ *
3454
+ * Written whole, and with new nodes, even when it reads the same:
3455
+ * the callers filter what is no news, and a count that went away
3456
+ * and came back IS news -- a new text node is a change a reader
3457
+ * announces.
3458
+ ************************************************************/
3459
+ function write_badge_news(gobj)
3460
+ {
3461
+ let priv = gobj.priv;
3462
+ let said = [];
3463
+ let $lines = [];
3464
+ for(let news of priv.badge_news) {
3465
+ if(said.includes(news.message)) {
3466
+ continue;
3467
+ }
3468
+ said.push(news.message);
3469
+ $lines.push(createElement2(
3470
+ ["div", {class: "SHELL_BADGE_NEWS"}, text_node(news.message)]
3471
+ ));
3472
+ }
3473
+ priv.badge_status.replaceChildren(...$lines);
3361
3474
  }
3362
3475
 
3363
3476
  /************************************************************
@@ -3479,6 +3592,21 @@ function ac_back_wait_timeout(gobj, event, kw, src)
3479
3592
  return 0;
3480
3593
  }
3481
3594
 
3595
+ /************************************************************
3596
+ * The turn in which badges changed is over (posted by the first
3597
+ * change, announce_badge()): the message in the live region is
3598
+ * complete, and a reader hears it as it stands. The next change
3599
+ * starts a message of its own -- added to this one, it would say
3600
+ * again what was already said.
3601
+ ************************************************************/
3602
+ function ac_close_badge_news(gobj, event, kw, src)
3603
+ {
3604
+ let priv = gobj.priv;
3605
+ priv.badge_news = [];
3606
+ priv.badge_news_closing = false;
3607
+ return 0;
3608
+ }
3609
+
3482
3610
  /************************************************************
3483
3611
  * Drawer backdrop click on a C_YUI_NAV child: the nav publishes
3484
3612
  * this so the shell can close the drawer through the canonical
@@ -3737,7 +3865,10 @@ function create_gclass(gclass_name)
3737
3865
  ["EV_NAV_ITEM_CLOSE", ac_nav_item_close, null],
3738
3866
  /* The wait for a history.back() of the shell is over: the
3739
3867
  * timer of defer_route() says so. */
3740
- ["EV_BACK_WAIT_TIMEOUT", ac_back_wait_timeout, null]
3868
+ ["EV_BACK_WAIT_TIMEOUT", ac_back_wait_timeout, null],
3869
+ /* The turn in which badges changed is over: posted to itself
3870
+ * by announce_badge(). */
3871
+ ["EV_CLOSE_BADGE_NEWS", ac_close_badge_news, null]
3741
3872
  ]]
3742
3873
  ];
3743
3874
 
@@ -3745,6 +3876,7 @@ function create_gclass(gclass_name)
3745
3876
  ["EV_NAV_CLICKED", 0],
3746
3877
  ["EV_DRAWER_CLOSE_REQUESTED", 0],
3747
3878
  ["EV_BACK_WAIT_TIMEOUT", 0],
3879
+ ["EV_CLOSE_BADGE_NEWS", 0],
3748
3880
  ["EV_NAV_ITEM_CLOSE", event_flag_t.EVF_OUTPUT_EVENT
3749
3881
  |event_flag_t.EVF_PUBLIC_EVENT
3750
3882
  |event_flag_t.EVF_NO_WARN_SUBS],
@@ -4005,9 +4137,9 @@ function yui_shell_previous_route(shell_gobj)
4005
4137
  /************************************************************
4006
4138
  * Resolve the shell that governs `gobj`: the nearest
4007
4139
  * C_YUI_SHELL ancestor, else the last shell created on the
4008
- * page (apps have exactly one). Null when no shell exists —
4009
- * callers must degrade loudly (shell_modals logs a warning
4010
- * and resolves the safe default).
4140
+ * page that is still alive (apps have exactly one). Null when
4141
+ * no shell exists — callers must degrade loudly (shell_modals
4142
+ * logs a warning and resolves the safe default).
4011
4143
  ************************************************************/
4012
4144
  function yui_shell_of(gobj)
4013
4145
  {
@@ -4018,7 +4150,7 @@ function yui_shell_of(gobj)
4018
4150
  }
4019
4151
  g = gobj_parent(g);
4020
4152
  }
4021
- return __last_shell__;
4153
+ return __live_shells__.length > 0 ? __live_shells__[__live_shells__.length - 1] : null;
4022
4154
  }
4023
4155
 
4024
4156
  /************************************************************
@@ -4542,7 +4674,9 @@ function yui_shell_set_toolbar_item_badge(shell_gobj, item_id, value, tone)
4542
4674
  if(now && now !== before) {
4543
4675
  let $item = $badge.closest("[data-toolbar-item-id]");
4544
4676
  const name_key = ($item && $item.getAttribute("data-i18n-aria-label")) || item_id;
4545
- announce_badge(shell_gobj, /* i18n: data */ name_key, now);
4677
+ announce_badge(shell_gobj, /* i18n: data */ name_key, now, `toolbar:${item_id}`);
4678
+ } else if(!now) {
4679
+ forget_badge_news(shell_gobj, `toolbar:${item_id}`);
4546
4680
  }
4547
4681
  }
4548
4682
 
@@ -4603,10 +4737,16 @@ function yui_shell_set_nav_item_badge(shell_gobj, item_id, value, tone)
4603
4737
  }
4604
4738
 
4605
4739
  /* Said ONCE, here, with the item's name -- not by each nav that
4606
- * draws the item (a rail, an icon bar, a drawer). */
4740
+ * draws the item (a rail, an icon bar, a drawer) -- and by the name
4741
+ * the nav gives it: its `name`, else its `aria_label`, else its id
4742
+ * (c_yui_nav.js item_li). Up to 7.26.41 an entry that declares only
4743
+ * an `aria_label` was said by its id. */
4607
4744
  let now = badge_text(badge);
4608
4745
  if(now && now !== before) {
4609
- announce_badge(shell_gobj, /* i18n: data */ item.name || item_id, now);
4746
+ announce_badge(shell_gobj, /* i18n: data */ item.name || item.aria_label || item_id,
4747
+ now, `nav:${item_id}`);
4748
+ } else if(!now) {
4749
+ forget_badge_news(shell_gobj, `nav:${item_id}`);
4610
4750
  }
4611
4751
  }
4612
4752
 
@@ -661,8 +661,9 @@ function build_graph(gobj)
661
661
  graph.setTheme(dark ? "dark" : "light");
662
662
 
663
663
  /* Tab goes from the graph to its own buttons: the main canvas in
664
- * the Tab order, the other layers out (g6_canvas_tab_order.js). */
665
- keep_canvas_tab_order(gobj, graph);
664
+ * the Tab order, named for what it draws, the other layers out
665
+ * (g6_canvas_tab_order.js). */
666
+ keep_canvas_tab_order(gobj, graph, "schema graph");
666
667
 
667
668
  /* The readout follows ANY camera change, the wheel included -- a
668
669
  * wheel notch passes through no action of ours. */
@@ -411,12 +411,12 @@ function apply_placement(gobj)
411
411
  * and it covered a toast where they met.
412
412
  *
413
413
  * The popup layer, not the window layer: the dock has to stay
414
- * above EVERY window, and windows live in two layers -- the
415
- * window layer (no `$parent`) and the popup layer, where the
416
- * site map and the JSON windows of the treedb views put theirs.
417
- * Above both; below the dialogs, the toasts and the loading
418
- * cover. No shell (before the first, between a logout and the
419
- * next login): the body.
414
+ * above EVERY window, and the windows live in the window layer
415
+ * -- since 7.26.35 the site map and the JSON windows of the
416
+ * treedb views too, which put theirs in the popup layer until
417
+ * then. The popup layer is above it; below the dialogs, the
418
+ * toasts and the loading cover. No shell (before the first,
419
+ * between a logout and the next login): the body.
420
420
  ************************************************************/
421
421
  function dock_place(gobj)
422
422
  {
@@ -0,0 +1,29 @@
1
+ /***********************************************************************
2
+ * g6_canvas_tab_order.css
3
+ *
4
+ * The focus ring of the main canvas of a G6 graph -- the one
5
+ * control of the graph in the Tab order, and named for what it
6
+ * draws (g6_canvas_tab_order.js gives it the `G6_MAIN_CANVAS`
7
+ * class). Brought along by that module, which every view that
8
+ * draws a G6 graph imports.
9
+ *
10
+ * G6 writes `outline: none` on its canvases, INLINE (configCanvasDom,
11
+ * when it builds them and on a renderer change), so a keyboard that
12
+ * Tabbed onto the graph saw no sign of where it was. An inline style
13
+ * is reached only by `!important`.
14
+ *
15
+ * `:focus-visible`, so a pointer that presses the graph -- and the
16
+ * views that give the canvas the keyboard on a press -- draw no
17
+ * ring. The colour is the link token as INK (`-on-scheme`, see the
18
+ * README's "Colour" convention), legible on the light and the dark
19
+ * scheme; inset, so a container that clips the graph does not clip
20
+ * the ring. No transition: a focus appears at once.
21
+ *
22
+ * Copyright (c) 2026, ArtGins.
23
+ * All Rights Reserved.
24
+ ***********************************************************************/
25
+
26
+ .G6_MAIN_CANVAS:focus-visible {
27
+ outline: 2px solid var(--bulma-link-on-scheme, var(--bulma-link, #485fc7)) !important;
28
+ outline-offset: -2px !important;
29
+ }
@@ -2,7 +2,7 @@
2
2
  * g6_canvas_tab_order.js
3
3
  *
4
4
  * The canvases of a G6 graph in the page's Tab order: the main
5
- * one in its place, the other layers out of it.
5
+ * one in its place, and NAMED; the other layers out of it.
6
6
  *
7
7
  * G6 stacks four canvases (background, main, label, transient)
8
8
  * and gives each of them `tabIndex = 1` (configCanvasDom, when it
@@ -15,6 +15,24 @@
15
15
  * to the graph's toolbars and buttons in DOM order; the other
16
16
  * layers receive nothing (`pointer-events: none`) and take -1.
17
17
  *
18
+ * A canvas in the Tab order is a control, and a control has a
19
+ * name: the main canvas carries a `title` and an `aria-label`,
20
+ * through t() and each with its key, that say WHICH graph it is
21
+ * -- the key is the view's, one per gclass ("json graph",
22
+ * "schema graph"...). From 7.26.28 to 7.26.41 Tab landed on it
23
+ * and a reader announced nothing. The keys are what a language
24
+ * switch reaches (refresh_language()), as on any control. It is
25
+ * a `region`, as maplibre makes its own canvas: a name on an
26
+ * element with no role is one ARIA forbids, and a reader is not
27
+ * bound to say it.
28
+ *
29
+ * And it can be SEEN when it has the focus: G6 writes `outline:
30
+ * none` on its canvases, inline, so a keyboard that Tabbed onto
31
+ * the graph had no sign of where it was. The main canvas takes
32
+ * the `G6_MAIN_CANVAS` class, and g6_canvas_tab_order.css --
33
+ * imported here, so it comes with the module to every view --
34
+ * draws a ring on it at `:focus-visible`.
35
+ *
18
36
  * Every view that creates a G6 Graph calls
19
37
  * keep_canvas_tab_order() right after `new Graph()`: the order is
20
38
  * put right each time G6 writes the 1 -- once the canvas is built
@@ -32,12 +50,16 @@ import {
32
50
  } from "@yuneta/gobj-js";
33
51
 
34
52
  import {GraphEvent} from "@antv/g6";
53
+ import {t} from "i18next";
54
+
55
+ import "./g6_canvas_tab_order.css";
35
56
 
36
57
  /************************************************************
37
- * Main canvas 0, every other layer -1. Returns 0, or -1 with
38
- * the cause logged.
58
+ * Main canvas 0, named by `name_key`, and marked for its
59
+ * focus ring; every other layer -1. Returns 0, or -1 with the
60
+ * cause logged.
39
61
  ************************************************************/
40
- function set_canvas_tab_order(gobj, graph)
62
+ function set_canvas_tab_order(gobj, graph, name_key)
41
63
  {
42
64
  let canvas = graph? graph.getCanvas() : null;
43
65
 
@@ -60,20 +82,30 @@ function set_canvas_tab_order(gobj, graph)
60
82
  ret = -1;
61
83
  continue;
62
84
  }
63
- $el.tabIndex = (name === "main")? 0 : -1;
85
+ if(name !== "main") {
86
+ $el.tabIndex = -1;
87
+ continue;
88
+ }
89
+ $el.tabIndex = 0;
90
+ $el.classList.add("G6_MAIN_CANVAS");
91
+ $el.setAttribute("role", "region");
92
+ $el.setAttribute("title", t(name_key));
93
+ $el.setAttribute("data-i18n-title", name_key);
94
+ $el.setAttribute("aria-label", t(name_key));
95
+ $el.setAttribute("data-i18n-aria-label", name_key);
64
96
  }
65
97
  return ret;
66
98
  }
67
99
 
68
100
  /************************************************************
69
- * Keep the order for the life of `graph`: on every moment G6
70
- * writes its own.
101
+ * Keep the order, and the name, for the life of `graph`: on
102
+ * every moment G6 writes its own.
71
103
  ************************************************************/
72
- function keep_canvas_tab_order(gobj, graph)
104
+ function keep_canvas_tab_order(gobj, graph, name_key)
73
105
  {
74
106
  for(let ev of [GraphEvent.AFTER_CANVAS_INIT, GraphEvent.AFTER_RENDERER_CHANGE]) {
75
107
  graph.on(ev, () => {
76
- set_canvas_tab_order(gobj, graph);
108
+ set_canvas_tab_order(gobj, graph, name_key);
77
109
  });
78
110
  }
79
111
  }