Moving board lists fails when label is deleted
Problem
When a Label is deleted, any existing board lists tied to that Label are also removed. The position of existing board lists are not updated to reflect the "gap" where the previous list existed.
Steps to reproduce:
- Create five labels (one, two, three, four, five)
- Create five board lists, each associated to the labels.
- Delete labels two and three
- Review the board list, which will have: Open, one, four, five, and Closed.
- Attempt to swap the position of four and five.
The error will occur, because board lists Four and Five still have their original "position" values and are likely greater than the board.lists.movable.size value.
Workarounds
UI
- If the first list is still in the "correct" position (at
position: 0), moving any other list to the front (right of "Open") will correctly update the positions. - If the first list is not in the "correct" position, and has a position value of anything other than 0, you must remove all board lists in that board. Any new lists created will increment from
0as expected.
Console
- get Id of the board (via GUI or API) and replace it in the script below
gitlab-rails console
board_lists = Board.find_by(id: 1).lists
board_lists.map.with_index { |l, index|
l.position=index-1 unless l.position == nil
l.save
}
This rearranges the lists with proper positions using their indexes on the board.
Proposed fix
- Schedule a recalculation of board list positions when a label is deleted,
- Adapt board position code somehow to allow for one or more missing lists.
Original issue description
Steps to repro
- Scope a board to
Milestone = None(ex: https://gitlab.com/groups/tech-marketing/demos/gitlab-agile-demo/awesome-co/-/boards/2768175?milestone_title=None) - Hide open/close lists
- Create a new list based on a label
- Attempt to move the list to a new position
Response
[{
"data": {
"updateBoardList": {
"list": {
"__typename": "BoardList",
"id": "gid://gitlab/List/9276481",
"title": "wf::4-refine",
"position": 6,
"listType": "label",
"collapsed": false,
"issuesCount": 0,
"label": {
"id": "gid://gitlab/GroupLabel/20130415",
"title": "wf::4-refine",
"color": "#808080",
"textColor": "#FFFFFF",
"description": "Refine Track - Step 4: Split and estimate work item",
"descriptionHtml": "Refine Track - Step 4: Split and estimate work item",
"__typename": "Label"
}
},
"errors": ["The update was not successful."],
"__typename": "UpdateBoardListPayload"
}
}
}]
Edited by John Hope
