-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: variable name changes when element name/label changes #893
Conversation
46575b0
to
2ca70f5
Compare
I don't see any changes regarding the decision table. Is it already present in that editor? I know that we don't support variable adding or modification in the decision table, but it could be present in the XML brought by user. |
fd81b34
to
0aced41
Compare
Since variables weren't available in the modeling interface, I initially assumed they weren't part of the decision tables. However, I've now fixed the issue for all elements to ensure everything is covered. |
bo.variable.name = newLabel; | ||
this._modeling.updateProperties(element, { variable: bo.variable }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bo.variable.name = newLabel;
This is a technique called monkey-patching. If you add tests for commandStack.undo
, you will notice that the change cannot be undone. We need to dispatch an updateProperties call which updates the variable name.
@philippfromme perhaps it makes sense you look into this together with @abdul99ahad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @barmac, for pointing this out. I discussed the monkey patching technique with @philippfromme earlier and I didn't realize that my implementation went against the recommended approach. I apologize for the oversight. I've updated the implementation to align with the correct approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice the comment I left. Let's add tests for undo, and fix the code. As I am off for the next two weeks, please ask @philippfromme or other team member for support.
0aced41
to
bf51fc5
Compare
4c5c344
to
e222864
Compare
I have fixed the code and added the test cases that support undo/redo |
@barmac @philippfromme We could move the |
Is there anything keeping us from handling both cases in a shared component? |
We can cover that case as well. I previously discussed this with @barmac, who mentioned that only a one-way sync is required as of now. |
packages/dmn-js-decision-table/test/spec/features/modeling/behavior/NameChangeBehaviorSpec.js
Outdated
Show resolved
Hide resolved
I will look into this today again. |
Note that the variable name change is not reflected in the literal expression editor: Screen.Recording.2024-09-13.at.10.40.49.mov |
Looks that it's an already existing issue. LiteralExpressionPropertiesEditorComponent does not update on external changes. |
The thing about this is that in the future, I expect that we replace dmn-js-literal-expression with dmn-js-boxed-expression entirely where you cannot change the variable name by design. Still, I think that, contrary to what I said before, for the external changes it makes sense to sync it two-way. |
Yes, the variable name is changing but the state is not updating. Hence, when you're on the same screen (lieral expression editor), the change doesn't reflect although its value has been updated. For variable name changing directly, the element name won't change since it's currently not supported. |
IMO the update should happen as it does in boxed expression. Let the field display the current value. |
@barmac need your support in updating the state externally as I'm stuck and can only update the state within the component. We might need to use Wrapper with ChangeSupport just like in boxed-expression. |
29ff0c0
to
2e6bb56
Compare
@@ -32,6 +32,21 @@ export default class LiteralExpressionPropertiesComponent extends Component { | |||
}); | |||
} | |||
|
|||
componentWillMount() { | |||
this._eventBus.on('elements.changed', this.onChange); | |||
console.log('componentDidUpdate',); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log('componentDidUpdate',); |
...tures/literal-expression-properties/components/LiteralExpressionPropertiesEditorComponent.js
Outdated
Show resolved
Hide resolved
2e6bb56
to
20f1582
Compare
The CI failure seems to be unrelated. I'll give it a second try. |
|
||
onChange = () => { | ||
const decision = this._viewer.getDecision(); | ||
if (decision.variable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
packages/dmn-js-drd/src/features/modeling/cmd/UpdatePropertiesHandler.js
Show resolved
Hide resolved
One optional improvement suggestion, but other than that it looks good. |
6f53c4a
to
6d1e6d6
Compare
6d1e6d6
to
b381471
Compare
} | ||
|
||
isElementVariable(element) { | ||
const variable = element.get('variable'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks when using this feature along with the dmn-js-properties-panel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. I can reproduce it on the Modeler nightly too.
Closes #863
Proposed Changes