Details
-
Bug
-
Status: Done
-
Low
-
Resolution: Done
-
6.4.0-p5
-
SR4J Sprint 91
-
0.7
Description
Steps to reproduce:
(Bug case)
1. Open Dashboard using any browser >> Navigate to the project's issue navigator
2. Click Create Issue >> Click the Component/s field
3. Type an existing component >> Select existing component (e.g. component_x)
4. Type a new component name with text found in the existing component chosen in step 3 (e.g. "x")
5. Observe Component/s field
Demo -
Sample Code:
import com.atlassian.jira.bc.project.component.ProjectComponent import com.atlassian.jira.component.ComponentAccessor def componentsField = getFieldById("components") def descriptionField = getFieldById("description") if (componentsField.getFormValue() instanceof String) { String value = componentsField.getFormValue() if (value.startsWith("nv")) { componentsField.setFormValue("") } } else if (componentsField.getFormValue() instanceof List) { String value = componentsField.getFormValue().toString() componentsField.setFormValue([]) StringTokenizer st = new StringTokenizer(value, ",") List<Long> newValues = new ArrayList<>(); while (st.hasMoreTokens()) { String token = st.nextToken().trim() if (!token.startsWith("nv_")) { if (token.startsWith("[")) { token = token.substring(1, token.length()) } if (token.endsWith("]")) { token = token.substring(0, token.length() - 1) } newValues.add(Long.parseLong(token)) } } if (newValues.size() == 1) { componentsField.setFormValue(newValues) } else { componentsField.setFormValue(newValues.join(",")) } descriptionField.setFormValue(newValues.toString()) }
Expected Output:
component_x is NOT removed, x is removed
Actual Output:
component_x is removed, x is removed
Note
Some words are success remove but some are not.
"component_x" with new value "x" fails.
"component_x" with new value "nent" fails.
"component_x" with new value "test" passes (erases the nv_test).
"component_x" with new value "component_xy" passes (erases the nv_component_xy).