Skip to content

Commit

Permalink
Orderlist: keep the correct order when moving multiple items to top o…
Browse files Browse the repository at this point in the history
…r bottom

When multiple items are selected and moved to the top or bottom of an OrderList at the same time, they are moved one by one in a loop until the entire selection has been moved.

To make sure that the item at the top of the selection (the selected item that is highest up in the current order) will still be at the top after the selection, we should move items in the right order: move the top item last when inserting at the top, and first when inserting at the bottom. Currently, this order is exactly reversed, meaning the selected items are reversed in those cases. 

This commit reverses both loop orders to fix this problem
  • Loading branch information
jeroenmuller authored Oct 26, 2023
1 parent 4dd5b46 commit 6a8f030
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/orderlist/OrderList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default {
if(this.d_selection) {
let value = [...this.value];
for (let i = 0; i < this.d_selection.length; i++) {
for (let i = this.d_selection.length - 1; i >= 0; i--) {
let selectedItem = this.d_selection[i];
let selectedItemIndex = ObjectUtils.findIndexInList(selectedItem, value);
Expand Down Expand Up @@ -164,7 +164,7 @@ export default {
if (this.d_selection) {
let value = [...this.value];
for (let i = this.d_selection.length - 1; i >= 0; i--) {
for (let i = 0; i < this.d_selection.length; i++) {
let selectedItem = this.d_selection[i];
let selectedItemIndex = ObjectUtils.findIndexInList(selectedItem, value);
Expand Down

0 comments on commit 6a8f030

Please sign in to comment.