Skip to content

Commit 70511e7

Browse files
authored
Update mixin-sorting.js
1 parent 688f63c commit 70511e7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/table/helpers/mixin-sorting.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,19 @@ export default {
9494
return this.computedFields.some(f => f.sortable)
9595
},
9696
sortedItems() {
97-
// Sorts the filtered items and returns a new array of the sorted items
98-
const items = (this.filteredItems || []).slice()
97+
// Sorts the filtered items and returns a new array of
98+
// the sorted items, or the original array if not sorted
99+
const items = this.filteredItems || this.localItems || []
99100
const sortBy = this.localSortBy
100101
const sortDesc = this.localSortDesc
101102
const sortCompare = this.sortCompare
102103
const localSorting = this.localSorting
103104
const sortOptions = { ...this.sortCompareOptions, usage: 'sort' }
104105
const sortLocale = this.sortCompareLocale || undefined
105106
const nullLast = this.sortNullLast
107+
const fieldsObj = this.computedFieldsObj
106108
if (sortBy && localSorting) {
107-
const field = this.computedFieldsObj[sortBy] || {}
109+
const field = fieldsObj[sortBy] || {}
108110
const sortByFormatted = field.sortByFormatted
109111
const formatter = isFunction(sortByFormatted)
110112
? sortByFormatted
@@ -136,6 +138,7 @@ export default {
136138
return (result || 0) * (sortDesc ? -1 : 1)
137139
})
138140
}
141+
// Else, return the original array
139142
return items
140143
}
141144
},

0 commit comments

Comments
 (0)