Browse Source

Merge pull request #5443 from Yang-Ming-Wang/fix-multi-select-row

Fix the bug of multiSelectRow
Dustin Utecht 5 years ago
parent
commit
908a674ea2
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/bootstrap-table.js

+ 3 - 2
src/bootstrap-table.js

@@ -2830,9 +2830,10 @@ class BootstrapTable {
 
     if (this.options.multipleSelectRow) {
       if (this.multipleSelectRowShiftKey && this.multipleSelectRowLastSelectedIndex >= 0) {
-        const indexes = [this.multipleSelectRowLastSelectedIndex, index].sort()
+        const [fromIndex, toIndex] = this.multipleSelectRowLastSelectedIndex < index ?
+          [this.multipleSelectRowLastSelectedIndex, index] : [index, this.multipleSelectRowLastSelectedIndex]
 
-        for (let i = indexes[0] + 1; i < indexes[1]; i++) {
+        for (let i = fromIndex + 1; i < toIndex; i++) {
           this.data[i][this.header.stateField] = true
           this.$selectItem.filter(`[data-index="${i}"]`).prop('checked', true)
         }