@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.
@@ -15,6 +15,13 @@
15
15
  * developer window of gui_agent, gui_treedb and wattyzer vanished
16
16
  * after a logout and a login. The dock, the same.
17
17
  *
18
+ * The gclass viewer opened from such a window follows it
19
+ * (REV-CLOUD V24.5.6): up to 7.26.41 it was told the element its
20
+ * opener hung from as its `$parent` -- the body, between a logout and
21
+ * the next login -- and stayed there after the login, above the new
22
+ * shell's dialogs. And with two shells alive, destroying the last one
23
+ * gives the windows to the other (it gave them to the body).
24
+ *
18
25
  * Copyright (c) 2026, ArtGins.
19
26
  * All Rights Reserved.
20
27
  ***********************************************************************/
@@ -30,6 +37,18 @@ if(typeof globalThis.matchMedia === "undefined") {
30
37
  globalThis.matchMedia = () => ({matches: false, addEventListener() {}, removeEventListener() {}});
31
38
  }
32
39
 
40
+ /* The gclass viewer watches its container; nothing resizes here. */
41
+ if(typeof globalThis.ResizeObserver === "undefined") {
42
+ globalThis.ResizeObserver = class {
43
+ observe() {
44
+ }
45
+ unobserve() {
46
+ }
47
+ disconnect() {
48
+ }
49
+ };
50
+ }
51
+
33
52
  const {
34
53
  SDATA, SDATA_END, data_type_t, gclass_create, gobj_write_attr,
35
54
  gobj_start_up, gobj_create_yuno, gobj_create, gobj_create_service,
@@ -40,6 +59,7 @@ const {register_c_yui_shell, yui_shell_window_layer, yui_shell_language_changed}
40
59
  const {register_c_yui_nav} = await import("./c_yui_nav.js");
41
60
  const {register_c_yui_window} = await import("./c_yui_window.js");
42
61
  const {register_c_yui_window_manager} = await import("./c_yui_window_manager.js");
62
+ const {open_gclass_view, close_gclass_view} = await import("./yui_gclass_view.js");
43
63
 
44
64
  const SRC = dirname(fileURLToPath(import.meta.url));
45
65
 
@@ -409,3 +429,97 @@ describe("the title of a dock chip changes language (REV-CLOUD V23, QA of estado
409
429
  logout(shell2);
410
430
  });
411
431
  });
432
+
433
+ describe("REV-CLOUD V24.5.6: a gclass viewer opened from a window goes where its opener goes", () => {
434
+ /* A view inside a window parented to the app: the frontend view in
435
+ * the developer window, whose `gclass` button opens the viewer. */
436
+ function window_with_a_view(name, kw)
437
+ {
438
+ const view = gobj_create(`${name}_view`, "C_TEST_LAYER_VIEW", {}, yuno);
439
+ const win = open_window(name, Object.assign({body: view}, kw || {}));
440
+ return {view, win};
441
+ }
442
+
443
+ test("opened between a logout and the next login: the next shell takes it in with its opener", () => {
444
+ const shell1 = build_shell();
445
+ const {view, win} = window_with_a_view(`gv_dev_${++seq}`);
446
+ logout(shell1);
447
+ expect(lives_in(win, document.body)).toBe(true);
448
+
449
+ const handle = open_gclass_view(view, "C_TEST_LAYER_VIEW", {});
450
+ expect(!!(handle && handle.win)).toBe(true);
451
+ expect(lives_in(handle.win, document.body)).toBe(true);
452
+
453
+ /* Login: both in the new shell's window layer, under its
454
+ * dialogs. Up to 7.26.41 the viewer stayed in the body. */
455
+ const shell2 = build_shell();
456
+ expect(lives_in(win, yui_shell_window_layer(shell2))).toBe(true);
457
+ expect(lives_in(handle.win, yui_shell_window_layer(shell2))).toBe(true);
458
+
459
+ close_gclass_view(handle);
460
+ close(win);
461
+ gobj_destroy(view);
462
+ logout(shell2);
463
+ expect(errors()).toEqual([]);
464
+ });
465
+
466
+ test("opened in a shell: beside its opener, and with it through a logout and a login", () => {
467
+ const shell1 = build_shell();
468
+ const {view, win} = window_with_a_view(`gv_in_${++seq}`);
469
+ const handle = open_gclass_view(view, "C_TEST_LAYER_VIEW", {});
470
+ expect(lives_in(handle.win, yui_shell_window_layer(shell1))).toBe(true);
471
+
472
+ logout(shell1);
473
+ expect(lives_in(win, document.body)).toBe(true);
474
+ expect(lives_in(handle.win, document.body)).toBe(true);
475
+
476
+ const shell2 = build_shell();
477
+ expect(lives_in(handle.win, yui_shell_window_layer(shell2))).toBe(true);
478
+
479
+ close_gclass_view(handle);
480
+ close(win);
481
+ gobj_destroy(view);
482
+ logout(shell2);
483
+ expect(errors()).toEqual([]);
484
+ });
485
+
486
+ test("opened from a window its host placed in an element of the page: beside it, there for good", () => {
487
+ const shell = build_shell();
488
+ const $mine = document.createElement("div");
489
+ document.body.appendChild($mine);
490
+ const {view, win} = window_with_a_view(`gv_placed_${++seq}`, {$parent: $mine});
491
+
492
+ /* Any other place is another stacking context: the viewer could
493
+ * open BEHIND the window it was opened from. */
494
+ const handle = open_gclass_view(view, "C_TEST_LAYER_VIEW", {});
495
+ expect(lives_in(handle.win, $mine)).toBe(true);
496
+ logout(shell);
497
+ const shell2 = build_shell();
498
+ expect(lives_in(handle.win, $mine)).toBe(true);
499
+
500
+ close_gclass_view(handle);
501
+ close(win);
502
+ gobj_destroy(view);
503
+ $mine.remove();
504
+ logout(shell2);
505
+ expect(errors()).toEqual([]);
506
+ });
507
+ });
508
+
509
+ describe("two shells alive: destroying the last one gives the windows to the other", () => {
510
+ test("the windows go to the shell that remains, not to the body", () => {
511
+ const first = build_shell();
512
+ const second = build_shell();
513
+ const w = open_window(`two_shells_${++seq}`);
514
+ expect(lives_in(w, yui_shell_window_layer(second))).toBe(true);
515
+
516
+ logout(second);
517
+ expect(lives_in(w, yui_shell_window_layer(first))).toBe(true);
518
+
519
+ logout(first);
520
+ expect(lives_in(w, document.body)).toBe(true);
521
+
522
+ close(w);
523
+ expect(errors()).toEqual([]);
524
+ });
525
+ });
@@ -43,7 +43,7 @@ import {
43
43
  import {describe_local_gclass} from "./gclass_describe.js";
44
44
  import {register_c_yui_gclass} from "./c_yui_gclass.js";
45
45
  import {yui_shell_show_error, yui_shell_show_modal} from "./shell_modals.js";
46
- import {yui_shell_of} from "./c_yui_shell.js";
46
+ import {yui_shell_of, yui_shell_window_layer} from "./c_yui_shell.js";
47
47
 
48
48
  import {t} from "i18next";
49
49
 
@@ -308,6 +308,17 @@ function close_gclass_view(handle)
308
308
  * lands BEHIND its opener whatever number it is given, and
309
309
  * the button reads as one that did nothing.
310
310
  *
311
+ * An opener in the place the shell gives every window -- its
312
+ * window layer, the body while there is none -- gives the
313
+ * viewer no `$parent` at all: the viewer takes that place too,
314
+ * and FOLLOWS the shell with its opener (C_YUI_WINDOW's
315
+ * ac_shell_changed). Up to 7.26.41 it was handed that element
316
+ * by name, and a name is a choice its host made: a viewer
317
+ * opened from the developer window between a logout and the
318
+ * next login was told "the body", and stayed there after the
319
+ * login -- above the new shell's dialogs -- while its opener
320
+ * moved into the shell.
321
+ *
311
322
  * Opened from no window: null -- the window layer of the
312
323
  * shell, where every window lives (the legacy '#top-layer'
313
324
  * when a page has one). It was the shell's popup layer: above
@@ -319,6 +330,10 @@ function window_layer_of(host)
319
330
  if($c && typeof $c.closest === "function") {
320
331
  let $win = $c.closest(".C_YUI_WINDOW");
321
332
  if($win && $win.parentNode) {
333
+ let $shell_place = yui_shell_window_layer(yui_shell_of(host)) || document.body;
334
+ if($win.parentNode === $shell_place) {
335
+ return null;
336
+ }
322
337
  return $win.parentNode;
323
338
  }
324
339
  }