Skip to content

Commit

Permalink
fix(client): disable editor actions if direct editing
Browse files Browse the repository at this point in the history
* properly disable editor actions when direct editing is active
* remove hacks

Closes #790
  • Loading branch information
philippfromme committed Jun 18, 2018
1 parent bc90f73 commit b7d59cb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
15 changes: 10 additions & 5 deletions app/lib/menu/menu-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ MenuBuilder.prototype.appendBpmnActions = function() {
this.menu.append(new MenuItem({
label: 'Edit Label',
accelerator: 'E',
enabled: this.opts.state.elementsSelected,
enabled: this.opts.state.elementsSelected && this.opts.state.inactiveInput,
click: function() {
app.emit('menu:action', 'directEditing');
}
Expand All @@ -365,7 +365,7 @@ MenuBuilder.prototype.appendBpmnActions = function() {

this.menu.append(new MenuItem({
label: 'Align Elements',
enabled: this.opts.state.elementsSelected,
enabled: this.opts.state.elementsSelected && this.opts.inactiveInput,
submenu: Menu.buildFromTemplate([
{
label: 'Align Left',
Expand Down Expand Up @@ -415,7 +415,7 @@ MenuBuilder.prototype.appendBpmnActions = function() {

this.menu.append(new MenuItem({
label: 'Distribute Elements',
enabled: this.opts.state.elementsSelected,
enabled: this.opts.state.elementsSelected && this.opts.inactiveInput,
submenu: Menu.buildFromTemplate([
{
label: 'Distribute Horizontally',
Expand All @@ -439,6 +439,7 @@ MenuBuilder.prototype.appendBpmnActions = function() {
this.menu.append(new MenuItem({
label: 'Find',
accelerator: 'CommandOrControl + F',
enabled: this.opts.state.inactiveInput,
click: function() {
app.emit('menu:action', 'find');
}
Expand All @@ -449,13 +450,15 @@ MenuBuilder.prototype.appendBpmnActions = function() {
this.menu.append(new MenuItem({
label: 'Move Elements to Origin',
accelerator: 'CommandOrControl+Shift+0',
enabled: this.opts.state.inactiveInput,
click: function() {
app.emit('menu:action', 'moveToOrigin');
}
}));

this.menu.append(new MenuItem({
label: 'Move Canvas',
enabled: this.opts.state.inactiveInput,
submenu: Menu.buildFromTemplate([{
label: 'Move Up',
accelerator: 'Up',
Expand Down Expand Up @@ -539,7 +542,7 @@ MenuBuilder.prototype.appendCmmnActions = function() {
this.menu.append(new MenuItem({
label: 'Edit Label',
accelerator: 'E',
enabled: this.opts.state.elementsSelected,
enabled: this.opts.state.elementsSelected && this.opts.state.inactiveInput,
click: function() {
app.emit('menu:action', 'directEditing');
}
Expand All @@ -550,6 +553,7 @@ MenuBuilder.prototype.appendCmmnActions = function() {
this.menu.append(new MenuItem({
label: 'Find',
accelerator: 'CommandOrControl + F',
enabled: this.opts.state.inactiveInput,
click: function() {
app.emit('menu:action', 'find');
}
Expand All @@ -559,6 +563,7 @@ MenuBuilder.prototype.appendCmmnActions = function() {

this.menu.append(new MenuItem({
label: 'Move Canvas',
enabled: this.opts.state.inactiveInput,
submenu: Menu.buildFromTemplate([{
label: 'Move Up',
accelerator: 'Up',
Expand Down Expand Up @@ -650,7 +655,7 @@ MenuBuilder.prototype.appendDmnActions = function() {
this.menu.append(new MenuItem({
label: 'Edit Label',
accelerator: 'E',
enabled: this.opts.state.elementsSelected,
enabled: this.opts.state.elementsSelected && this.opts.state.inactiveInput,
click: function() {
app.emit('menu:action', 'directEditing');
}
Expand Down
8 changes: 1 addition & 7 deletions client/lib/app/editor/bpmn-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,6 @@ BpmnEditor.prototype.triggerEditorActions = function(action, options) {
};
}

// ignore all editor actions (besides the following three)
// if there's a current active input or textarea
if ([ 'removeSelection', 'stepZoom', 'zoom', 'find' ].indexOf(action) === -1 && isInputActive()) {
return;
}

debug('editor-actions', action, opts);

// forward other actions to editor actions
Expand Down Expand Up @@ -273,7 +267,7 @@ BpmnEditor.prototype.updateState = function() {
stateContext = assign(stateContext, {
undo: commandStack.canUndo(),
redo: commandStack.canRedo(),
elementsSelected: elementsSelected && !inputActive,
elementsSelected: elementsSelected,
dirty: dirty,
zoom: true,
editable: true,
Expand Down
8 changes: 1 addition & 7 deletions client/lib/app/editor/cmmn-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,6 @@ CmmnEditor.prototype.triggerEditorActions = function(action, options) {
}, options);
}

// ignore all editor actions (besides the following three)
// if there's a current active input or textarea
if ([ 'removeSelection', 'stepZoom', 'zoom' ].indexOf(action) === -1 && isInputActive()) {
return;
}

debug('editor-actions', action, opts);

// forward other actions to editor actions
Expand Down Expand Up @@ -213,7 +207,7 @@ CmmnEditor.prototype.updateState = function() {
stateContext = assign(stateContext, {
undo: commandStack.canUndo(),
redo: commandStack.canRedo(),
elementsSelected: elementsSelected && !inputActive,
elementsSelected: elementsSelected,
dirty: dirty,
zoom: true,
editable: true,
Expand Down
2 changes: 0 additions & 2 deletions client/lib/app/editor/dmn-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ DmnEditor.prototype.updateState = function(options = {}) {

stateContext.elementsSelected = !!selection.get().length;

// TODO(philippfromme): fix, this always returns false
// when wrapping this with setTimeout it works as expected
var inputActive = isInputActive();

stateContext.inactiveInput = !inputActive;
Expand Down

0 comments on commit b7d59cb

Please sign in to comment.