diff --git a/packages/dmn-js-decision-table/src/features/add-rule/AddRule.js b/packages/dmn-js-decision-table/src/features/add-rule/AddRule.js index 5fe6eae60..ff7743fb0 100644 --- a/packages/dmn-js-decision-table/src/features/add-rule/AddRule.js +++ b/packages/dmn-js-decision-table/src/features/add-rule/AddRule.js @@ -1,13 +1,20 @@ import AddRuleFootComponent from './components/AddRuleFootComponent'; export default class AddRule { - constructor(components, editorActions, eventBus) { + constructor(components, editorActions, eventBus, selection) { components.onGetComponent('table.foot', () => AddRuleFootComponent); - eventBus.on('addRule', () => { - editorActions.trigger('addRule'); + eventBus.on('addRule', (e, context) => { + const rule = editorActions.trigger('addRule'); + const colIndex = context.colIndex; + + if (rule.cells[colIndex]) { + selection.select(rule.cells[colIndex]); + } else { + selection.select(rule.cells[0]); + } }); } } -AddRule.$inject = [ 'components', 'editorActions', 'eventBus' ]; \ No newline at end of file +AddRule.$inject = [ 'components', 'editorActions', 'eventBus', 'selection' ]; \ No newline at end of file diff --git a/packages/dmn-js-decision-table/src/features/add-rule/components/AddRuleFootComponent.js b/packages/dmn-js-decision-table/src/features/add-rule/components/AddRuleFootComponent.js index adb63a533..fe3c19588 100644 --- a/packages/dmn-js-decision-table/src/features/add-rule/components/AddRuleFootComponent.js +++ b/packages/dmn-js-decision-table/src/features/add-rule/components/AddRuleFootComponent.js @@ -20,11 +20,11 @@ export default class AddRuleFootComponent extends Component { handleClick = (e) => { e.stopPropagation(); - this.addRule(); + this.addRule(e.target.dataset.colIndex); } - addRule() { - this._eventBus.fire('addRule'); + addRule(colIndex) { + this._eventBus.fire('addRule', { colIndex }); } render() { @@ -62,7 +62,7 @@ export default class AddRuleFootComponent extends Component { className += ' annotation'; } - cells.push(