Skip to content

Commit

Permalink
fix: focus canvas on attach
Browse files Browse the repository at this point in the history
This ensures that users can do modeling operations right away.
  • Loading branch information
nikku committed Nov 20, 2024
1 parent 0f8af12 commit 0eb28f0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions client/src/app/tabs/bpmn/BpmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ export class BpmnEditor extends CachedComponent {
listen(fn) {
const modeler = this.getModeler();

modeler[fn]('attach', this.handleAttach);

[
'import.done',
'saveXML.done',
Expand Down Expand Up @@ -303,6 +305,12 @@ export class BpmnEditor extends CachedComponent {
});
};

handleAttach = (event) => {
const modeler = this.getModeler();

modeler.get('canvas').focus();
};

handleError = (event) => {
const {
error
Expand Down
10 changes: 9 additions & 1 deletion client/src/app/tabs/cloud-bpmn/BpmnEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ export class BpmnEditor extends CachedComponent {
listen(fn) {
const modeler = this.getModeler();

modeler[fn]('attach', this.handleAttach);

[
'import.done',
'saveXML.done',
Expand All @@ -217,7 +219,7 @@ export class BpmnEditor extends CachedComponent {
'elements.copied',
'propertiesPanel.focusin',
'propertiesPanel.focusout',
'canvas.focus.changed',
'canvas.focus.changed'
].forEach((event) => {
modeler[fn](event, this.handleChanged);
});
Expand Down Expand Up @@ -295,6 +297,12 @@ export class BpmnEditor extends CachedComponent {
});
};

handleAttach = (event) => {
const modeler = this.getModeler();

modeler.get('canvas').focus();
};

handleError = (event) => {
const {
error
Expand Down
1 change: 1 addition & 0 deletions client/test/mocks/bpmn-js/Modeler.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default class Modeler {
resized() {},
isFocused() { return true; },
restoreFocus() {},
focus() {}
},
clipboard: {
isEmpty() {}
Expand Down

0 comments on commit 0eb28f0

Please sign in to comment.