Bulk Edit of Labels - Adding labels to multiple issues adds too many labels
Summary
When editing multiple issues by using the checkboxes in the issues list, then adding a single label and updating all issues, too many labels are added to the checked issues. It seems like other labels from the selected issues were spread over to all selected issues. Instead only the newly selected label(s) must be added to the selected issues.
This applies to whatever version is running on the domain https://gitlab.com right now. I do not have a local installation. (Emphasis required by past misunderstandings.)
Steps to reproduce
- Select multiple issues that already have different labels
- Add one new label
- Save changes
What is the current bug behavior?
Issues get labels that they should not have. This can be seen by looking at the recent changes to an issue. I only wanted to add one label but instead multiple labels were added along with it.
What is the expected correct behavior?
Only the selected label(s) should be added, nothing else.
Relevant logs and/or screenshots
Here I added the "dashboard" label and others were added with it. I had to find the errors and fix them manually for each issue.
Possible Root Causes
From this comment (#228616 (comment 378855132)):
The problem is in setOriginalDropdownData()
where we compute this:
setOriginalDropdownData() {
const $labelSelect = $('.bulk-update .js-label-select');
const dirtyLabelIds = $labelSelect.data('marked') || [];
const chosenLabelIds = [...this.getOriginalMarkedIds(), ...dirtyLabelIds];
$labelSelect.data('common', this.getOriginalCommonIds());
$labelSelect.data('marked', chosenLabelIds);
$labelSelect.data('indeterminate', this.getOriginalIndeterminateIds());
},
I think the issue here is in dirtyLabelIds
because we do $labelSelect.data('marked')
. This means those that were previously marked
will always be marked
and will not be changed back to indeterminate
.
Maybe this should be the marked IDs minus those that are in the common IDs.