camunda-bpmn-js 5.4.0 → 5.4.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.
@@ -10339,6 +10339,7 @@
10339
10339
  * deferUpdate?: boolean;
10340
10340
  * width?: number;
10341
10341
  * height?: number;
10342
+ * autoFocus?: boolean;
10342
10343
  * } } CanvasConfig
10343
10344
  * @typedef { {
10344
10345
  * group: SVGElement;
@@ -10525,18 +10526,20 @@
10525
10526
 
10526
10527
  attr(svg, 'tabindex', 0);
10527
10528
 
10528
- eventBus.on('element.hover', () => {
10529
+ config.autoFocus && eventBus.on('element.hover', () => {
10529
10530
  this.restoreFocus();
10530
10531
  });
10531
10532
 
10533
+ eventBus.on('element.mousedown', 500, (event) => {
10534
+ this.focus();
10535
+ });
10536
+
10532
10537
  svg.addEventListener('focusin', () => {
10533
- this._focused = true;
10534
- eventBus.fire('canvas.focus.changed', { focused: true });
10538
+ this._setFocused(true);
10535
10539
  });
10536
10540
 
10537
10541
  svg.addEventListener('focusout', () => {
10538
- this._focused = false;
10539
- eventBus.fire('canvas.focus.changed', { focused: false });
10542
+ this._setFocused(false);
10540
10543
  });
10541
10544
 
10542
10545
  append(container, svg);
@@ -10606,6 +10609,17 @@
10606
10609
  delete this._viewport;
10607
10610
  };
10608
10611
 
10612
+ Canvas.prototype._setFocused = function(focused) {
10613
+
10614
+ if (focused == this._focused) {
10615
+ return;
10616
+ }
10617
+
10618
+ this._focused = focused;
10619
+
10620
+ this._eventBus.fire('canvas.focus.changed', { focused });
10621
+ };
10622
+
10609
10623
  Canvas.prototype._clear = function() {
10610
10624
 
10611
10625
  const allElements = this._elementRegistry.getAll();
@@ -10630,10 +10644,12 @@
10630
10644
  };
10631
10645
 
10632
10646
  /**
10633
- * Sets focus on the canvas SVG element.
10634
- */
10647
+ * Sets focus on the canvas SVG element.
10648
+ */
10635
10649
  Canvas.prototype.focus = function() {
10636
10650
  this._svg.focus({ preventScroll: true });
10651
+
10652
+ this._setFocused(true);
10637
10653
  };
10638
10654
 
10639
10655
  /**
@@ -23944,12 +23960,19 @@
23944
23960
 
23945
23961
  var context;
23946
23962
 
23963
+ function handleMousedown(event) {
23964
+ return handleStart(event.originalEvent);
23965
+ }
23947
23966
 
23948
23967
  // listen for move on element mouse down;
23949
23968
  // allow others to hook into the event before us though
23950
23969
  // (dragging / element moving will do this)
23951
- eventBus.on('element.mousedown', 500, function(e) {
23952
- return handleStart(e.originalEvent);
23970
+ eventBus.on('canvas.focus.changed', function(event) {
23971
+ if (event.focused) {
23972
+ eventBus.on('element.mousedown', 500, handleMousedown);
23973
+ } else {
23974
+ eventBus.off('element.mousedown', handleMousedown);
23975
+ }
23953
23976
  });
23954
23977
 
23955
23978
 
@@ -24137,8 +24160,8 @@
24137
24160
 
24138
24161
  var self = this;
24139
24162
 
24140
- eventBus.on('canvas.init', function(e) {
24141
- self._init(config.enabled !== false);
24163
+ eventBus.on('canvas.focus.changed', function(event) {
24164
+ self._init(event.focused && config.enabled !== false);
24142
24165
  });
24143
24166
  }
24144
24167
 
@@ -24185,8 +24208,7 @@
24185
24208
 
24186
24209
  ZoomScroll.prototype._handleWheel = function handleWheel(event) {
24187
24210
 
24188
- // event is already handled by '.djs-scrollable'
24189
- if (closest(event.target, '.djs-scrollable', true)) {
24211
+ if (!this._canvas.isFocused()) {
24190
24212
  return;
24191
24213
  }
24192
24214