Переглянути джерело

Table: current row will set to the row which has the same row-key when data changes(#3023) (#13200)

Harlan 6 роки тому
батько
коміт
0d526b8371
1 змінених файлів з 14 додано та 0 видалено
  1. 14 0
      packages/table/src/table-store.js

+ 14 - 0
packages/table/src/table-store.js

@@ -597,6 +597,20 @@ TableStore.prototype.updateCurrentRow = function() {
   const oldCurrentRow = states.currentRow;
 
   if (data.indexOf(oldCurrentRow) === -1) {
+    if (states.rowKey && oldCurrentRow) {
+      let newCurrentRow = null;
+      for (let i = 0; i < data.length; i++) {
+        const item = data[i];
+        if (item && item[states.rowKey] === oldCurrentRow[states.rowKey]) {
+          newCurrentRow = item;
+          break;
+        }
+      }
+      if (newCurrentRow) {
+        states.currentRow = newCurrentRow;
+        return;
+      }
+    }
     states.currentRow = null;
 
     if (states.currentRow !== oldCurrentRow) {