@yuneta/gobj-ui 7.18.1 → 7.18.2

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.
@@ -53934,7 +53934,8 @@ function mt_destroy$1(gobj) {
53934
53934
  priv._on_language_changed = null;
53935
53935
  }
53936
53936
  if (priv._on_pointerdown_focus) {
53937
- priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus);
53937
+ priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus, true);
53938
+ priv.$container.removeEventListener("click", priv._on_pointerdown_focus, true);
53938
53939
  priv._on_pointerdown_focus = null;
53939
53940
  }
53940
53941
  if (priv.theme_observer) {
@@ -54108,10 +54109,11 @@ function configure_events(gobj) {
54108
54109
  if (target.closest("input, textarea, select, [contenteditable]")) return;
54109
54110
  if (target.closest(".g6-confirm-popover, .g6-create-popover,.g6-node-popover, .g6-edge-popover")) return;
54110
54111
  }
54111
- let $canvas = priv.$container.querySelector("canvas");
54112
+ let $canvas = main_canvas_of(priv.$container);
54112
54113
  if ($canvas && typeof $canvas.focus === "function") $canvas.focus({ preventScroll: true });
54113
54114
  };
54114
- priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus);
54115
+ priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus, true);
54116
+ priv.$container.addEventListener("click", priv._on_pointerdown_focus, true);
54115
54117
  graph.on("keydown", (evt) => {
54116
54118
  let ctrl = !!(evt.ctrlKey || evt.metaKey);
54117
54119
  if (ctrl && (evt.key === "a" || evt.key === "A")) {
@@ -55604,6 +55606,22 @@ function perform_history_op(gobj, is_redo) {
55604
55606
  }
55605
55607
  }
55606
55608
  /************************************************************
55609
+ * The canvas G6 listens on.
55610
+ *
55611
+ * A G6 graph stacks four canvases and gives every one of them a
55612
+ * `tabIndex`, so `querySelector("canvas")` finds a focusable
55613
+ * element that receives nothing: only the MAIN layer carries the
55614
+ * listeners, and it is the only one G6 leaves with pointer events
55615
+ * (`configCanvasDom` sets `pointerEvents: none` on the rest).
55616
+ * Focusing the wrong one looks exactly like focusing the right one
55617
+ * and delivers no key.
55618
+ ************************************************************/
55619
+ function main_canvas_of($container) {
55620
+ let canvases = $container.querySelectorAll("canvas");
55621
+ for (let i = 0; i < canvases.length; i++) if (window.getComputedStyle(canvases[i]).pointerEvents !== "none") return canvases[i];
55622
+ return canvases[0] || null;
55623
+ }
55624
+ /************************************************************
55607
55625
  * The selection.
55608
55626
  *
55609
55627
  * G6's `selected` element state IS the selection: `drag-element`
@@ -53921,7 +53921,8 @@ function mt_destroy$1(gobj) {
53921
53921
  priv._on_language_changed = null;
53922
53922
  }
53923
53923
  if (priv._on_pointerdown_focus) {
53924
- priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus);
53924
+ priv.$container.removeEventListener("pointerdown", priv._on_pointerdown_focus, true);
53925
+ priv.$container.removeEventListener("click", priv._on_pointerdown_focus, true);
53925
53926
  priv._on_pointerdown_focus = null;
53926
53927
  }
53927
53928
  if (priv.theme_observer) {
@@ -54095,10 +54096,11 @@ function configure_events(gobj) {
54095
54096
  if (target.closest("input, textarea, select, [contenteditable]")) return;
54096
54097
  if (target.closest(".g6-confirm-popover, .g6-create-popover,.g6-node-popover, .g6-edge-popover")) return;
54097
54098
  }
54098
- let $canvas = priv.$container.querySelector("canvas");
54099
+ let $canvas = main_canvas_of(priv.$container);
54099
54100
  if ($canvas && typeof $canvas.focus === "function") $canvas.focus({ preventScroll: true });
54100
54101
  };
54101
- priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus);
54102
+ priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus, true);
54103
+ priv.$container.addEventListener("click", priv._on_pointerdown_focus, true);
54102
54104
  graph.on("keydown", (evt) => {
54103
54105
  let ctrl = !!(evt.ctrlKey || evt.metaKey);
54104
54106
  if (ctrl && (evt.key === "a" || evt.key === "A")) {
@@ -55591,6 +55593,22 @@ function perform_history_op(gobj, is_redo) {
55591
55593
  }
55592
55594
  }
55593
55595
  /************************************************************
55596
+ * The canvas G6 listens on.
55597
+ *
55598
+ * A G6 graph stacks four canvases and gives every one of them a
55599
+ * `tabIndex`, so `querySelector("canvas")` finds a focusable
55600
+ * element that receives nothing: only the MAIN layer carries the
55601
+ * listeners, and it is the only one G6 leaves with pointer events
55602
+ * (`configCanvasDom` sets `pointerEvents: none` on the rest).
55603
+ * Focusing the wrong one looks exactly like focusing the right one
55604
+ * and delivers no key.
55605
+ ************************************************************/
55606
+ function main_canvas_of($container) {
55607
+ let canvases = $container.querySelectorAll("canvas");
55608
+ for (let i = 0; i < canvases.length; i++) if (window.getComputedStyle(canvases[i]).pointerEvents !== "none") return canvases[i];
55609
+ return canvases[0] || null;
55610
+ }
55611
+ /************************************************************
55594
55612
  * The selection.
55595
55613
  *
55596
55614
  * G6's `selected` element state IS the selection: `drag-element`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.18.1",
3
+ "version": "7.18.2",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -462,7 +462,10 @@ function mt_destroy(gobj)
462
462
 
463
463
  if(priv._on_pointerdown_focus) {
464
464
  priv.$container.removeEventListener(
465
- "pointerdown", priv._on_pointerdown_focus
465
+ "pointerdown", priv._on_pointerdown_focus, true
466
+ );
467
+ priv.$container.removeEventListener(
468
+ "click", priv._on_pointerdown_focus, true
466
469
  );
467
470
  priv._on_pointerdown_focus = null;
468
471
  }
@@ -818,12 +821,22 @@ function configure_events(gobj)
818
821
  return;
819
822
  }
820
823
  }
821
- let $canvas = priv.$container.querySelector("canvas");
824
+ let $canvas = main_canvas_of(priv.$container);
822
825
  if($canvas && typeof $canvas.focus === "function") {
823
826
  $canvas.focus({preventScroll: true});
824
827
  }
825
828
  };
826
- priv.$container.addEventListener("pointerdown", priv._on_pointerdown_focus);
829
+ /* Capture, and on the click as well as the press. Capture because
830
+ * the cards are DOM and may stop the press from bubbling; the
831
+ * click too because the browser does its OWN focus handling on
832
+ * mousedown, after ours, and it sends the focus to <body> when
833
+ * what was pressed cannot take it -- which a card cannot. */
834
+ priv.$container.addEventListener(
835
+ "pointerdown", priv._on_pointerdown_focus, true
836
+ );
837
+ priv.$container.addEventListener(
838
+ "click", priv._on_pointerdown_focus, true
839
+ );
827
840
 
828
841
  /* The canvas carries a `tabIndex` of its own, so a keydown reaches
829
842
  * us only while the GRAPH has focus. That is what keeps Ctrl+A in
@@ -3125,6 +3138,30 @@ function perform_history_op(gobj, is_redo)
3125
3138
  }
3126
3139
  }
3127
3140
 
3141
+ /************************************************************
3142
+ * The canvas G6 listens on.
3143
+ *
3144
+ * A G6 graph stacks four canvases and gives every one of them a
3145
+ * `tabIndex`, so `querySelector("canvas")` finds a focusable
3146
+ * element that receives nothing: only the MAIN layer carries the
3147
+ * listeners, and it is the only one G6 leaves with pointer events
3148
+ * (`configCanvasDom` sets `pointerEvents: none` on the rest).
3149
+ * Focusing the wrong one looks exactly like focusing the right one
3150
+ * and delivers no key.
3151
+ ************************************************************/
3152
+ function main_canvas_of($container)
3153
+ {
3154
+ let canvases = $container.querySelectorAll("canvas");
3155
+
3156
+ for(let i = 0; i < canvases.length; i++) {
3157
+ if(window.getComputedStyle(canvases[i]).pointerEvents !== "none") {
3158
+ return canvases[i];
3159
+ }
3160
+ }
3161
+
3162
+ return canvases[0] || null;
3163
+ }
3164
+
3128
3165
  /************************************************************
3129
3166
  * The selection.
3130
3167
  *