-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: empty whitespaces label in group #2237
base: develop
Are you sure you want to change the base?
Conversation
lib/util/LabelUtil.js
Outdated
@@ -251,7 +251,10 @@ export function setLabel(element, text) { | |||
if (attr) { | |||
|
|||
if (attr === 'categoryValueRef') { | |||
semantic['categoryValueRef'].value = text; | |||
if (!semantic[attr]) { | |||
return; |
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.
Watch for the contract of this function. If you early return, I propose you return element
to not break it.
Alternative:
if (semantic[attr]) {
// do change
}
My follow-up question is: Who calls this, and why, after the label has been removed? Will it ever be called with a non-empty text (in which case the above code would shadow a deeper issue?
Safe choice would be to be strict (ignore update only, if label is empty and categoryValueRef
is unset).
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.
I would agree to early return the element
.
The updateLabel
event calls this method. Even if we remove the existing label, it is updated via this method. It is not called after the label is removed, but rather when we are updating the label during execute
lifecycle.
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.
If the text is not empty, the label.create
event will be fired and setCategoryValue
function will be invoked in file GroupBehavior.js
. So, in case the label is not empty, we will have categoryValueRef
.
@@ -251,7 +251,10 @@ export function setLabel(element, text) { | |||
if (attr) { | |||
|
|||
if (attr === 'categoryValueRef') { | |||
semantic['categoryValueRef'].value = text; | |||
if (!semantic[attr]) { |
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.
if (!semantic[attr]) { | |
// ignore update to non-existing category value when removing the text | |
if (!text && !semantic[attr]) { |
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 would match my first preferred suggestion of my initial approach: #2231 (comment)
It should be safe for all use cases - at least those I came across.
Closes #2231
Proposed Changes
Checklist
To ensure you provided everything we need to look at your PR:
@bpmn-io/sr
toolCloses {LINK_TO_ISSUE}
orRelated to {LINK_TO_ISSUE}