bpmn-io / dmn-js

View and edit DMN diagrams in the browser.
https://bpmn.io/toolkit/dmn-js/
Other
296 stars 137 forks source link

fix(literal-expression): avoid translate to fail with undefined typeRef #748

Closed vpellegrino closed 1 year ago

vpellegrino commented 1 year ago

Closes https://github.com/camunda/web-modeler/issues/4252

There are situations when the typeRef related to a Literal Expression is just undefined. In these situations an error is thrown:

react_devtools_backend.js:2655 unhandled error in event listener TypeError: Cannot read properties of undefined (reading 'replace')
    at LiteralExpressionPropertiesComponent.translate [as _translate] (translate.js?e4f0:27:1)
    at LiteralExpressionPropertiesComponent.render (LiteralExpressionPropertiesComponent.js?7b38:13:415)

image

With the proposed change, the translate function would return undefined (instead of blocking with an error), so the hyphen will be shown for this particular "Variable Type": image

vpellegrino commented 1 year ago

@nikku I cannot set you as a reviewer, but a reviewer from your side would be highly appreciated.

nikku commented 1 year ago

I cannot reproduce the issue on our demo, stock dmn-js with the example you provided.

vpellegrino commented 1 year ago

I cannot reproduce the issue on our demo, stock dmn-js with the example you provided.

The website you provided is opening a dmn editor. Where can I access a dmn viewer instead, please?

nikku commented 1 year ago

@vpellegrino Ah, that was the context that I was missing. Will try to reproduce against the viewer and create a test case for it.

nikku commented 1 year ago

Thanks for your contribution. Works for me.

nikku commented 1 year ago

@vpellegrino https://github.com/bpmn-io/dmn-js/pull/749 adds missing test coverage for this one. Please have a look.

You can run test coverage using the following command:

npm run dev -- dmn-js-literal-expression
vpellegrino commented 1 year ago

That's great! Thanks for covering this test case @nikku

nikku commented 1 year ago

Released in v14.1.2.