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.
@@ -10328,6 +10328,7 @@
10328
10328
  * deferUpdate?: boolean;
10329
10329
  * width?: number;
10330
10330
  * height?: number;
10331
+ * autoFocus?: boolean;
10331
10332
  * } } CanvasConfig
10332
10333
  * @typedef { {
10333
10334
  * group: SVGElement;
@@ -10514,18 +10515,20 @@
10514
10515
 
10515
10516
  attr(svg, 'tabindex', 0);
10516
10517
 
10517
- eventBus.on('element.hover', () => {
10518
+ config.autoFocus && eventBus.on('element.hover', () => {
10518
10519
  this.restoreFocus();
10519
10520
  });
10520
10521
 
10522
+ eventBus.on('element.mousedown', 500, (event) => {
10523
+ this.focus();
10524
+ });
10525
+
10521
10526
  svg.addEventListener('focusin', () => {
10522
- this._focused = true;
10523
- eventBus.fire('canvas.focus.changed', { focused: true });
10527
+ this._setFocused(true);
10524
10528
  });
10525
10529
 
10526
10530
  svg.addEventListener('focusout', () => {
10527
- this._focused = false;
10528
- eventBus.fire('canvas.focus.changed', { focused: false });
10531
+ this._setFocused(false);
10529
10532
  });
10530
10533
 
10531
10534
  append(container, svg);
@@ -10595,6 +10598,17 @@
10595
10598
  delete this._viewport;
10596
10599
  };
10597
10600
 
10601
+ Canvas.prototype._setFocused = function(focused) {
10602
+
10603
+ if (focused == this._focused) {
10604
+ return;
10605
+ }
10606
+
10607
+ this._focused = focused;
10608
+
10609
+ this._eventBus.fire('canvas.focus.changed', { focused });
10610
+ };
10611
+
10598
10612
  Canvas.prototype._clear = function() {
10599
10613
 
10600
10614
  const allElements = this._elementRegistry.getAll();
@@ -10619,10 +10633,12 @@
10619
10633
  };
10620
10634
 
10621
10635
  /**
10622
- * Sets focus on the canvas SVG element.
10623
- */
10636
+ * Sets focus on the canvas SVG element.
10637
+ */
10624
10638
  Canvas.prototype.focus = function() {
10625
10639
  this._svg.focus({ preventScroll: true });
10640
+
10641
+ this._setFocused(true);
10626
10642
  };
10627
10643
 
10628
10644
  /**
@@ -23933,12 +23949,19 @@
23933
23949
 
23934
23950
  var context;
23935
23951
 
23952
+ function handleMousedown(event) {
23953
+ return handleStart(event.originalEvent);
23954
+ }
23936
23955
 
23937
23956
  // listen for move on element mouse down;
23938
23957
  // allow others to hook into the event before us though
23939
23958
  // (dragging / element moving will do this)
23940
- eventBus.on('element.mousedown', 500, function(e) {
23941
- return handleStart(e.originalEvent);
23959
+ eventBus.on('canvas.focus.changed', function(event) {
23960
+ if (event.focused) {
23961
+ eventBus.on('element.mousedown', 500, handleMousedown);
23962
+ } else {
23963
+ eventBus.off('element.mousedown', handleMousedown);
23964
+ }
23942
23965
  });
23943
23966
 
23944
23967
 
@@ -24126,8 +24149,8 @@
24126
24149
 
24127
24150
  var self = this;
24128
24151
 
24129
- eventBus.on('canvas.init', function(e) {
24130
- self._init(config.enabled !== false);
24152
+ eventBus.on('canvas.focus.changed', function(event) {
24153
+ self._init(event.focused && config.enabled !== false);
24131
24154
  });
24132
24155
  }
24133
24156
 
@@ -24174,8 +24197,7 @@
24174
24197
 
24175
24198
  ZoomScroll.prototype._handleWheel = function handleWheel(event) {
24176
24199
 
24177
- // event is already handled by '.djs-scrollable'
24178
- if (closest(event.target, '.djs-scrollable', true)) {
24200
+ if (!this._canvas.isFocused()) {
24179
24201
  return;
24180
24202
  }
24181
24203