From 0d526b8371441f541a18b970128b9dfe57b14845 Mon Sep 17 00:00:00 2001 From: Harlan Date: Wed, 31 Oct 2018 16:42:34 +0800 Subject: [PATCH] Table: current row will set to the row which has the same row-key when data changes(#3023) (#13200) --- packages/table/src/table-store.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/table/src/table-store.js b/packages/table/src/table-store.js index 074e7674f..3f3ad43ab 100644 --- a/packages/table/src/table-store.js +++ b/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) {