From 20f15828635c4c1716df48f3b1757f15515f1344 Mon Sep 17 00:00:00 2001 From: Abdul Ahad Date: Tue, 17 Sep 2024 15:06:17 +0200 Subject: [PATCH] fix: variable name state updating --- ...eralExpressionPropertiesEditorComponent.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/dmn-js-literal-expression/src/features/literal-expression-properties/components/LiteralExpressionPropertiesEditorComponent.js b/packages/dmn-js-literal-expression/src/features/literal-expression-properties/components/LiteralExpressionPropertiesEditorComponent.js index fcbde9cfb..edb58f05b 100644 --- a/packages/dmn-js-literal-expression/src/features/literal-expression-properties/components/LiteralExpressionPropertiesEditorComponent.js +++ b/packages/dmn-js-literal-expression/src/features/literal-expression-properties/components/LiteralExpressionPropertiesEditorComponent.js @@ -12,7 +12,7 @@ export default class LiteralExpressionPropertiesComponent extends Component { this._viewer = context.injector.get('viewer'); this._modeling = context.injector.get('modeling'); this._dataTypes = context.injector.get('dataTypes'); - + this._eventBus = context.injector.get('eventBus'); const decision = this._viewer.getDecision(); this.state = { @@ -32,6 +32,23 @@ export default class LiteralExpressionPropertiesComponent extends Component { }); } + componentWillMount() { + this._eventBus.on('elements.changed', this.onChange); + } + + componentWillUnmount() { + this._eventBus.off('elements.changed', this.onChange); + } + + onChange = () => { + const decision = this._viewer.getDecision(); + if (decision.variable) { + this.setState({ + name: decision.variable.name + }); + } + }; + setVariableType(typeRef) { if (typeRef === '') { this._modeling.editVariableType(undefined);