Skip to content

Commit d5f0dd2

Browse files
author
Sergii Kovalenko
committed
MAGETWO-63321: Issue when deleting item from Product options grid containing more than 20 options
1 parent 367e740 commit d5f0dd2

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ define([
156156
dnd: '${ $.dndConfig.name }'
157157
},
158158
pages: 1,
159-
pageSize: 20,
159+
pageSize: 2,
160160
relatedData: [],
161161
currentPage: 1,
162162
recordDataCache: [],
@@ -167,8 +167,7 @@ define([
167167
* Sets record data to cache
168168
*/
169169
setRecordDataToCache: function (data) {
170-
this.recordDataCache = this.recordDataCache && data.length > this.recordDataCache.length ?
171-
data : this.recordDataCache;
170+
this.recordDataCache = data;
172171
},
173172

174173
/**
@@ -625,6 +624,19 @@ define([
625624
this.pages(pages);
626625
},
627626

627+
/**
628+
* Reinit record data in order to remove deleted values
629+
*
630+
* @return void
631+
*/
632+
reinitRecordData: function () {
633+
this.recordData(
634+
_.filter(this.recordData(), function (elem) {
635+
return elem && elem[this.deleteProperty] !== this.deleteValue;
636+
}, this)
637+
);
638+
},
639+
628640
/**
629641
* Get items to rendering on current page
630642
*
@@ -827,8 +839,7 @@ define([
827839
deleteRecord: function (index, recordId) {
828840
var recordInstance,
829841
lastRecord,
830-
recordsData,
831-
childs;
842+
recordsData;
832843

833844
if (this.deleteProperty) {
834845
recordInstance = _.find(this.elems(), function (elem) {
@@ -840,11 +851,8 @@ define([
840851
this.removeMaxPosition();
841852
this.recordData()[recordInstance.index][this.deleteProperty] = this.deleteValue;
842853
this.recordData.valueHasMutated();
843-
childs = this.getChildItems();
844-
845-
if (childs.length > this.elems().length) {
846-
this.addChild(false, childs[childs.length - 1][this.identificationProperty], false);
847-
}
854+
this.reinitRecordData();
855+
this.reload();
848856
} else {
849857
this.update = true;
850858

0 commit comments

Comments
 (0)