camunda-bpmn-js 5.4.1 → 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.
@@ -4936,6 +4936,7 @@
4936
4936
  * deferUpdate?: boolean;
4937
4937
  * width?: number;
4938
4938
  * height?: number;
4939
+ * autoFocus?: boolean;
4939
4940
  * } } CanvasConfig
4940
4941
  * @typedef { {
4941
4942
  * group: SVGElement;
@@ -5122,18 +5123,20 @@
5122
5123
 
5123
5124
  attr$1(svg, 'tabindex', 0);
5124
5125
 
5125
- eventBus.on('element.hover', () => {
5126
+ config.autoFocus && eventBus.on('element.hover', () => {
5126
5127
  this.restoreFocus();
5127
5128
  });
5128
5129
 
5130
+ eventBus.on('element.mousedown', 500, (event) => {
5131
+ this.focus();
5132
+ });
5133
+
5129
5134
  svg.addEventListener('focusin', () => {
5130
- this._focused = true;
5131
- eventBus.fire('canvas.focus.changed', { focused: true });
5135
+ this._setFocused(true);
5132
5136
  });
5133
5137
 
5134
5138
  svg.addEventListener('focusout', () => {
5135
- this._focused = false;
5136
- eventBus.fire('canvas.focus.changed', { focused: false });
5139
+ this._setFocused(false);
5137
5140
  });
5138
5141
 
5139
5142
  append(container, svg);
@@ -5203,6 +5206,17 @@
5203
5206
  delete this._viewport;
5204
5207
  };
5205
5208
 
5209
+ Canvas.prototype._setFocused = function(focused) {
5210
+
5211
+ if (focused == this._focused) {
5212
+ return;
5213
+ }
5214
+
5215
+ this._focused = focused;
5216
+
5217
+ this._eventBus.fire('canvas.focus.changed', { focused });
5218
+ };
5219
+
5206
5220
  Canvas.prototype._clear = function() {
5207
5221
 
5208
5222
  const allElements = this._elementRegistry.getAll();
@@ -5227,10 +5241,12 @@
5227
5241
  };
5228
5242
 
5229
5243
  /**
5230
- * Sets focus on the canvas SVG element.
5231
- */
5244
+ * Sets focus on the canvas SVG element.
5245
+ */
5232
5246
  Canvas.prototype.focus = function() {
5233
5247
  this._svg.focus({ preventScroll: true });
5248
+
5249
+ this._setFocused(true);
5234
5250
  };
5235
5251
 
5236
5252
  /**
@@ -25957,12 +25973,19 @@
25957
25973
 
25958
25974
  var context;
25959
25975
 
25976
+ function handleMousedown(event) {
25977
+ return handleStart(event.originalEvent);
25978
+ }
25960
25979
 
25961
25980
  // listen for move on element mouse down;
25962
25981
  // allow others to hook into the event before us though
25963
25982
  // (dragging / element moving will do this)
25964
- eventBus.on('element.mousedown', 500, function(e) {
25965
- return handleStart(e.originalEvent);
25983
+ eventBus.on('canvas.focus.changed', function(event) {
25984
+ if (event.focused) {
25985
+ eventBus.on('element.mousedown', 500, handleMousedown);
25986
+ } else {
25987
+ eventBus.off('element.mousedown', handleMousedown);
25988
+ }
25966
25989
  });
25967
25990
 
25968
25991
 
@@ -26150,8 +26173,8 @@
26150
26173
 
26151
26174
  var self = this;
26152
26175
 
26153
- eventBus.on('canvas.init', function(e) {
26154
- self._init(config.enabled !== false);
26176
+ eventBus.on('canvas.focus.changed', function(event) {
26177
+ self._init(event.focused && config.enabled !== false);
26155
26178
  });
26156
26179
  }
26157
26180
 
@@ -26198,8 +26221,7 @@
26198
26221
 
26199
26222
  ZoomScroll.prototype._handleWheel = function handleWheel(event) {
26200
26223
 
26201
- // event is already handled by '.djs-scrollable'
26202
- if (closest(event.target, '.djs-scrollable', true)) {
26224
+ if (!this._canvas.isFocused()) {
26203
26225
  return;
26204
26226
  }
26205
26227