Orderlist: keep the correct order when moving multiple items to top or 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
pull/4701/head
jeroenmuller 2023-10-26 18:56:26 +02:00 committed by GitHub
parent 4dd5b46a2f
commit 6a8f030206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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);
@ -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);