瀏覽代碼

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) {