Skip to content

Commit 0f948ac

Browse files
committed
Fixed a js bug where ui_component labels have the wrong sort order.
1 parent 373bd01 commit 0f948ac

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

app/code/Magento/Ui/view/base/web/js/dynamic-rows/dynamic-rows.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,13 @@ define([
548548
});
549549

550550
this.labels.push(data);
551+
552+
/**
553+
* Sort the array after an element was added to fix an bug where
554+
* additional added field labels in ui_components haven't the right
555+
* sort order.
556+
*/
557+
this.labels.sort(this._compare);
551558
}, this);
552559
}
553560
},
@@ -914,6 +921,24 @@ define([
914921
}));
915922
},
916923

924+
/**
925+
* Compare two objects by the sortOrder property.
926+
*
927+
* @param {Object} $object1
928+
* @param {Object} $object2
929+
* @returns {Number}
930+
* @private
931+
*/
932+
_compare: function ($object1, $object2) {
933+
if ($object1.sortOrder > $object2.sortOrder) {
934+
return 1;
935+
} else if ($object1.sortOrder < $object2.sortOrder) {
936+
return -1;
937+
}
938+
939+
return 0;
940+
},
941+
917942
/**
918943
* Set new data to dataSource,
919944
* delete element

0 commit comments

Comments
 (0)