@yuneta/gobj-ui 7.26.40 → 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.
Files changed (39) hide show
  1. package/README.md +325 -65
  2. package/dist/gobj-ui.cjs.js +418 -176
  3. package/dist/gobj-ui.es.js +418 -176
  4. package/package.json +1 -1
  5. package/scripts/validate-locales.mjs +644 -142
  6. package/src/c_g6_nodes_tree.js +3 -2
  7. package/src/c_yui_form.js +80 -68
  8. package/src/c_yui_fsm_graph.js +3 -2
  9. package/src/c_yui_gobj_tree_js.js +3 -2
  10. package/src/c_yui_json_graph.js +3 -2
  11. package/src/c_yui_nav.js +43 -28
  12. package/src/c_yui_schema_editor.css +16 -0
  13. package/src/c_yui_schema_editor.js +61 -17
  14. package/src/c_yui_shell.js +199 -59
  15. package/src/c_yui_treedb_schema.js +3 -2
  16. package/src/c_yui_window_manager.js +6 -6
  17. package/src/form_table_edits_ask.wiring.test.js +398 -0
  18. package/src/form_table_rearm.wiring.test.js +9 -7
  19. package/src/g6_canvas_tab_order.css +29 -0
  20. package/src/g6_canvas_tab_order.js +41 -9
  21. package/src/g6_canvas_tab_order.wiring.test.js +107 -1
  22. package/src/i18n_key_functions.js +41 -25
  23. package/src/i18n_key_functions.test.js +178 -2
  24. package/src/modal_guard_back.wiring.test.js +135 -0
  25. package/src/named_controls.wiring.test.js +270 -6
  26. package/src/nav_cards_helpers.js +9 -4
  27. package/src/nav_item_badge.wiring.test.js +163 -15
  28. package/src/route_map_model.js +59 -10
  29. package/src/route_map_model.test.js +90 -0
  30. package/src/schema_editor_openers.wiring.test.js +283 -0
  31. package/src/shell_modals.js +24 -4
  32. package/src/shell_route_map.js +15 -3
  33. package/src/shell_section_index.js +3 -1
  34. package/src/window_layer.wiring.test.js +114 -0
  35. package/src/yui_gclass_view.js +16 -1
  36. package/src/yui_tabulator_i18n.js +21 -1
  37. package/src/yui_tabulator_i18n.test.js +39 -0
  38. package/src/yui_text.js +10 -0
  39. package/src/yui_text.test.js +13 -0
@@ -0,0 +1,398 @@
1
+ /***********************************************************************
2
+ * form_table_edits_ask.wiring.test.js
3
+ *
4
+ * What the reader does to the TABLES of a C_YUI_FORM is `edited`,
5
+ * whatever the record the form opened with -- so closing asks.
6
+ *
7
+ * A form opens CHANGED when its record lacks a field the template
8
+ * fills with its default. Until 7.26.40 that also unwired the
9
+ * tables' `dataChanged` (and only a save, an undo or a load of what
10
+ * is stored wired it again), so adding a row, editing a cell,
11
+ * deleting a row or editing a nested table marked nothing: since
12
+ * 7.26.39 the close asks only for `edited`, and it closed without a
13
+ * question -- the edit lost. In estadodelaire that is the settings of
14
+ * every device without its alarm colours, whose alarms are tables.
15
+ *
16
+ * And the column titles of those tables change language: they were
17
+ * drawn at build and never again.
18
+ *
19
+ * Driven through the real gclass on a document double, with a
20
+ * Tabulator double that, like Tabulator, draws a row (its formatter
21
+ * runs) and says `dataChanged` INSIDE addRow(), synchronously.
22
+ *
23
+ * Copyright (c) 2026, ArtGins.
24
+ * All Rights Reserved.
25
+ ***********************************************************************/
26
+ import {describe, test, expect, beforeAll, beforeEach, vi} from "vitest";
27
+ import {install_dom_double} from "../test/dom_double.js";
28
+
29
+ install_dom_double();
30
+
31
+ if(typeof globalThis.ResizeObserver === "undefined") {
32
+ globalThis.ResizeObserver = class {
33
+ observe() {}
34
+ unobserve() {}
35
+ disconnect() {}
36
+ };
37
+ }
38
+
39
+ const tables = vi.hoisted(() => []);
40
+ vi.mock("tabulator-tables", () => {
41
+ class FakeTabulator {
42
+ constructor($el, settings) {
43
+ this.element = $el;
44
+ this.settings = settings;
45
+ this.options = {};
46
+ this.handlers = {};
47
+ this.initialized = true;
48
+ this.rows = [];
49
+ this.installed = {};
50
+ this.locale = null;
51
+ this.modules = {
52
+ localize: {
53
+ installLang: (name, strings) => {
54
+ this.installed[name] = strings;
55
+ }
56
+ }
57
+ };
58
+ tables.push(this);
59
+ return new Proxy(this, {
60
+ get(target, prop) {
61
+ if(prop in target) {
62
+ return target[prop];
63
+ }
64
+ return () => [];
65
+ }
66
+ });
67
+ }
68
+ on(ev, fn) {
69
+ (this.handlers[ev] = this.handlers[ev] || []).push(fn);
70
+ }
71
+ off(ev) {
72
+ delete this.handlers[ev];
73
+ }
74
+ emit(ev) {
75
+ for(const fn of (this.handlers[ev] || [])) {
76
+ fn([]);
77
+ }
78
+ }
79
+ addRow(record) {
80
+ /* The row's element lives in the table's, as in Tabulator:
81
+ * a nested table drawn in it is inside the form. */
82
+ const $row = document.createElement("div");
83
+ this.element.appendChild($row);
84
+ const row = {getElement: () => $row, getData: () => record};
85
+ if(this.settings && typeof this.settings.rowFormatter === "function") {
86
+ this.settings.rowFormatter(row);
87
+ }
88
+ this.rows.push(row);
89
+ this.emit("dataChanged");
90
+ return Promise.resolve(row);
91
+ }
92
+ /* What the trash of a row ends in (row.delete()). */
93
+ delete_row() {
94
+ const row = this.rows.pop();
95
+ row.getElement().remove();
96
+ this.emit("dataChanged");
97
+ }
98
+ /* What an edited cell says. */
99
+ edit_cell() {
100
+ this.emit("dataChanged");
101
+ }
102
+ validate() {
103
+ return true;
104
+ }
105
+ clearData() {
106
+ for(const row of this.rows) {
107
+ row.getElement().remove();
108
+ }
109
+ this.rows = [];
110
+ }
111
+ setLocale(name) {
112
+ this.locale = name;
113
+ }
114
+ destroy() {
115
+ }
116
+ }
117
+ return {TabulatorFull: FakeTabulator, Tabulator: FakeTabulator};
118
+ });
119
+
120
+ const {
121
+ SDATA_END, gclass_create,
122
+ gobj_start_up, gobj_create_yuno, gobj_create_pure_child,
123
+ gobj_start, gobj_send_event, gobj_read_attr,
124
+ set_log_callback,
125
+ } = await import("@yuneta/gobj-js");
126
+ const {register_c_yui_form} = await import("./c_yui_form.js");
127
+ const i18next = (await import("i18next")).default;
128
+
129
+ const logged = [];
130
+ let yuno = null;
131
+
132
+ /* A device's settings, cut down: a defaulted field, and the alarms as
133
+ * a table whose rows carry a nested table of triggers. */
134
+ const TEMPLATE = {
135
+ template_version: {
136
+ type: "integer",
137
+ default: 7,
138
+ flag: ["hidden", "persistent"]
139
+ },
140
+ level: {
141
+ type: "integer",
142
+ default: 3,
143
+ flag: ["writable", "persistent"]
144
+ },
145
+ alarms: {
146
+ type: "array",
147
+ flag: ["writable", "persistent", "table"],
148
+ table: {
149
+ name: {
150
+ type: "string",
151
+ header: "alarm name",
152
+ flag: ["writable", "persistent"]
153
+ },
154
+ triggers: {
155
+ type: "array",
156
+ flag: ["writable", "persistent", "table"],
157
+ table: {
158
+ measure: {
159
+ type: "string",
160
+ header: "measure",
161
+ flag: ["writable", "persistent"]
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
167
+ };
168
+
169
+ /* `level` missing: the form opens changed. */
170
+ const LACKING = {
171
+ template_version: 7,
172
+ alarms: [{name: "hot", triggers: [{measure: "temperature"}]}]
173
+ };
174
+
175
+ const COMPLETE = {
176
+ template_version: 7,
177
+ level: 3,
178
+ alarms: [{name: "hot", triggers: [{measure: "temperature"}]}]
179
+ };
180
+
181
+ beforeAll(async () => {
182
+ await i18next.init({
183
+ lng: "en",
184
+ resources: {
185
+ en: {translation: {"alarm name": "Alarm name", "measure": "Measure"}},
186
+ es: {translation: {"alarm name": "Nombre de la alarma", "measure": "Medida"}}
187
+ }
188
+ });
189
+ gobj_start_up(null, null, null, null, null, null, null);
190
+ set_log_callback((level, msg) => {
191
+ logged.push({level: String(level), msg: String(msg)});
192
+ });
193
+ gclass_create("C_TEST_TE_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
194
+ gclass_create(
195
+ "C_TEST_TE_APP",
196
+ [["EV_SAVE_RECORD", 0]],
197
+ [["ST_IDLE", [
198
+ ["EV_SAVE_RECORD", () => 0, null],
199
+ ]]],
200
+ {}, 0, [SDATA_END()], {}, 0, 0, 0, 0
201
+ );
202
+ register_c_yui_form();
203
+ yuno = gobj_create_yuno("form_table_edits_yuno", "C_TEST_TE_HOST", {});
204
+ gobj_start(yuno);
205
+ });
206
+
207
+ beforeEach(async () => {
208
+ logged.length = 0;
209
+ await i18next.changeLanguage("en");
210
+ });
211
+
212
+ let seq = 0;
213
+
214
+ function build(record)
215
+ {
216
+ const first = tables.length;
217
+ const app = gobj_create_pure_child(`teapp${++seq}`, "C_TEST_TE_APP", {}, yuno);
218
+ gobj_start(app);
219
+ const form = gobj_create_pure_child(`teform${seq}`, "C_YUI_FORM", {
220
+ template: TEMPLATE,
221
+ record: record,
222
+ editable: true,
223
+ }, app);
224
+ gobj_start(form);
225
+ return {form, first};
226
+ }
227
+
228
+ /* The tables the form built since `first`: the alarms table first,
229
+ * then a triggers table per alarm row drawn. */
230
+ function built(first)
231
+ {
232
+ return tables.slice(first);
233
+ }
234
+
235
+ /* The microtasks of addRow().then(): the nested rows load there. */
236
+ async function settle()
237
+ {
238
+ await new Promise(resolve => setTimeout(resolve, 0));
239
+ }
240
+
241
+ function close_asks(form)
242
+ {
243
+ const kw = {abort_close: false};
244
+ gobj_send_event(form, "EV_WINDOW_TO_CLOSE", kw, form);
245
+ return kw.abort_close ? (kw.warning || "(no warning)") : "";
246
+ }
247
+
248
+ function errors()
249
+ {
250
+ return logged.filter(l => /error/i.test(l.level) || /ERROR/.test(l.msg));
251
+ }
252
+
253
+ describe("a form that opens changed hears what the reader does to its tables", () => {
254
+ test("it opens changed, not edited, and closes without asking", async () => {
255
+ const {form, first} = build(LACKING);
256
+ await settle();
257
+ expect(gobj_read_attr(form, "changes")).toBe(true);
258
+ expect(gobj_read_attr(form, "edited")).toBe(false);
259
+ expect(built(first).length).toBe(2); // the alarms, and the triggers of its row
260
+ expect(close_asks(form)).toBe("");
261
+ expect(errors()).toEqual([]);
262
+ });
263
+
264
+ test("an edited cell makes it ask", async () => {
265
+ const {form, first} = build(LACKING);
266
+ await settle();
267
+ built(first)[0].edit_cell();
268
+ expect(gobj_read_attr(form, "edited")).toBe(true);
269
+ expect(close_asks(form)).toBe("all changes will be lost");
270
+ expect(errors()).toEqual([]);
271
+ });
272
+
273
+ test("a deleted row makes it ask", async () => {
274
+ const {form, first} = build(LACKING);
275
+ await settle();
276
+ built(first)[0].delete_row();
277
+ expect(close_asks(form)).toBe("all changes will be lost");
278
+ });
279
+
280
+ test("a row the reader adds makes it ask; the rows the form loads do not", async () => {
281
+ const {form, first} = build(LACKING);
282
+ await settle();
283
+ const alarms = built(first)[0];
284
+ expect(alarms.rows.length).toBe(1); // loaded: no question
285
+ expect(close_asks(form)).toBe("");
286
+
287
+ /* What the table's add button sends: the reader's row. */
288
+ const tables_before = tables.length;
289
+ gobj_send_event(form, "EV_ADD_TABLE_ROW", {
290
+ table_id: alarms.element.yui_table_id,
291
+ record: {},
292
+ loading: false
293
+ }, form);
294
+ expect(alarms.rows.length).toBe(2);
295
+ expect(tables.length).toBe(tables_before + 1); // the new row's triggers table
296
+ expect(gobj_read_attr(form, "edited")).toBe(true);
297
+ expect(close_asks(form)).toBe("all changes will be lost");
298
+ expect(errors()).toEqual([]);
299
+ });
300
+
301
+ test("an edit of a NESTED table makes it ask, also one drawn after the load", async () => {
302
+ const loaded = build(LACKING);
303
+ await settle();
304
+ const triggers = built(loaded.first)[1];
305
+ expect(triggers.rows.length).toBe(1); // loaded in its row: no question
306
+ expect(close_asks(loaded.form)).toBe("");
307
+ triggers.edit_cell();
308
+ expect(close_asks(loaded.form)).toBe("all changes will be lost");
309
+
310
+ /* An undo draws the rows again, and each row builds its triggers
311
+ * table then: a table that did not exist when the form loaded. */
312
+ const before_undo = tables.length;
313
+ gobj_send_event(loaded.form, "EV_UNDO_RECORD", {}, loaded.form);
314
+ await settle();
315
+ expect(close_asks(loaded.form)).toBe("");
316
+ const redrawn = tables.slice(before_undo);
317
+ expect(redrawn.length).toBe(1);
318
+ expect(redrawn[0].rows.length).toBe(1);
319
+ redrawn[0].edit_cell();
320
+ expect(close_asks(loaded.form)).toBe("all changes will be lost");
321
+ expect(errors()).toEqual([]);
322
+ });
323
+
324
+ test("a record loaded LATER that lacks a field (a reload, a refused save) still hears them", async () => {
325
+ const {form, first} = build(COMPLETE);
326
+ await settle();
327
+ expect(gobj_read_attr(form, "changes")).toBe(false);
328
+ gobj_send_event(form, "EV_LOAD_RECORD", LACKING, form);
329
+ await settle();
330
+ expect(gobj_read_attr(form, "changes")).toBe(true);
331
+ expect(gobj_read_attr(form, "edited")).toBe(false);
332
+ expect(close_asks(form)).toBe("");
333
+ built(first)[0].edit_cell();
334
+ expect(close_asks(form)).toBe("all changes will be lost");
335
+ expect(errors()).toEqual([]);
336
+ });
337
+
338
+ test("a table built after the load (tableBuilt) takes its rows without a question", async () => {
339
+ const {form, first} = build(COMPLETE);
340
+ await settle();
341
+ const alarms = built(first)[0];
342
+ /* A table not built yet: no rows, and the ones it is given wait
343
+ * for its `tableBuilt`. */
344
+ alarms.clearData();
345
+ alarms.initialized = false;
346
+ gobj_send_event(form, "EV_LOAD_RECORD", LACKING, form);
347
+ await settle();
348
+ expect(alarms.rows.length).toBe(0);
349
+ /* Tabulator builds the table now, long after the load returned. */
350
+ alarms.initialized = true;
351
+ alarms.emit("tableBuilt");
352
+ await settle();
353
+ expect(alarms.rows.length).toBe(1);
354
+ expect(gobj_read_attr(form, "edited")).toBe(false);
355
+ expect(close_asks(form)).toBe("");
356
+ expect(errors()).toEqual([]);
357
+ });
358
+
359
+ test("with a complete record it asks as before", async () => {
360
+ /* The waits are the 200 ms after which 7.26.40 wired the tables
361
+ * again: with them this case passes on the code before too. */
362
+ const wait = () => new Promise(resolve => setTimeout(resolve, 260));
363
+ const {form, first} = build(COMPLETE);
364
+ await wait();
365
+ expect(gobj_read_attr(form, "changes")).toBe(false);
366
+ built(first)[1].edit_cell();
367
+ expect(close_asks(form)).toBe("all changes will be lost");
368
+ gobj_send_event(form, "EV_SAVE_RECORD", {}, form);
369
+ expect(close_asks(form)).toBe("");
370
+ await wait();
371
+ built(first)[0].edit_cell();
372
+ expect(close_asks(form)).toBe("all changes will be lost");
373
+ expect(errors()).toEqual([]);
374
+ });
375
+ });
376
+
377
+ describe("the column titles of the tables change language", () => {
378
+ test("each table, nested ones too, is given its titles in the new language", async () => {
379
+ const {form, first} = build(COMPLETE);
380
+ await settle();
381
+ const [alarms, triggers] = built(first);
382
+
383
+ await i18next.changeLanguage("es");
384
+ gobj_send_event(form, "EV_LANGUAGE_CHANGED", {}, form);
385
+
386
+ expect(alarms.locale).toBeTruthy();
387
+ expect(alarms.installed[alarms.locale].columns).toEqual({
388
+ name: "Nombre de la alarma",
389
+ triggers: "triggers"
390
+ });
391
+ expect(triggers.installed[triggers.locale].columns).toEqual({measure: "Medida"});
392
+ /* No column was rebuilt to get there: the rows (and the nested
393
+ * table) are the ones loaded. */
394
+ expect(alarms.rows.length).toBe(1);
395
+ expect(triggers.rows.length).toBe(1);
396
+ expect(errors()).toEqual([]);
397
+ });
398
+ });
@@ -5,11 +5,13 @@
5
5
  * a save or an undo -- which is what a dialog does: it closes the
6
6
  * moment the record is saved.
7
7
  *
8
- * set_changed_stated(false) re-wires the tables' `dataChanged` from
9
- * a 200 ms timer. Since 7.26.7 destroy_ui() destroys the widgets and
10
- * nulls `$table.tabulator`, and the timer, left running, called
11
- * `.on()` on that null: an uncaught TypeError. The timer is kept and
12
- * cancelled now, and it skips a table that is gone.
8
+ * set_changed_stated(false) used to re-wire the tables' `dataChanged`
9
+ * from a 200 ms timer. Since 7.26.7 destroy_ui() destroys the widgets
10
+ * and nulls `$table.tabulator`, and the timer, left running, called
11
+ * `.on()` on that null: an uncaught TypeError. Since 7.26.41 there is
12
+ * no timer: each table is wired once, when it is built, and stays
13
+ * wired (form_table_edits_ask.wiring.test.js says why). These cases
14
+ * keep guarding the destroy right after a save or an undo.
13
15
  *
14
16
  * Copyright (c) 2026, ArtGins.
15
17
  * All Rights Reserved.
@@ -117,7 +119,7 @@ function build(rows)
117
119
  }
118
120
 
119
121
  describe("a form with a table, destroyed right after", () => {
120
- test("an undo: the deferred re-wiring does not throw", async () => {
122
+ test("an undo, then the destroy: nothing left behind throws", async () => {
121
123
  const {form} = build();
122
124
  expect(tables.length).toBeGreaterThan(0);
123
125
  const errors = [];
@@ -135,7 +137,7 @@ describe("a form with a table, destroyed right after", () => {
135
137
  expect(errors).toEqual([]);
136
138
  });
137
139
 
138
- test("a live form is still re-wired", async () => {
140
+ test("a live form's table stays wired, once", async () => {
139
141
  const {form} = build();
140
142
  const table = tables[tables.length - 1];
141
143
  gobj_send_event(form, "EV_UNDO_RECORD", {}, form);
@@ -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
  }