Skip to content

Commit c29f802

Browse files
PeanutWatsonFAKER-A
authored andcommitted
Table: not emit triggers sort-change during initialization (ElemeFE#14625)
1 parent df4e778 commit c29f802

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/table/src/table-header.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ export default {
210210

211211
mounted() {
212212
const { prop, order } = this.defaultSort;
213-
this.store.commit('sort', { prop, order });
213+
const init = true;
214+
this.store.commit('sort', { prop, order, init });
214215
},
215216

216217
beforeDestroy() {

packages/table/src/table-store.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ TableStore.prototype.mutations = {
259259
changeSortCondition(states, options) {
260260
states.data = sortData((states.filteredData || states._data || []), states);
261261

262-
if (!options || !options.silent) {
262+
if (!options || !(options.silent || options.init)) {
263263
this.table.$emit('sort-change', {
264264
column: this.states.sortingColumn,
265265
prop: this.states.sortProp,
@@ -271,7 +271,7 @@ TableStore.prototype.mutations = {
271271
},
272272

273273
sort(states, options) {
274-
const { prop, order } = options;
274+
const { prop, order, init } = options;
275275
if (prop) {
276276
states.sortProp = prop;
277277
states.sortOrder = order || 'ascending';
@@ -286,7 +286,9 @@ TableStore.prototype.mutations = {
286286
}
287287

288288
if (states.sortingColumn) {
289-
this.commit('changeSortCondition');
289+
this.commit('changeSortCondition', {
290+
init: init
291+
});
290292
}
291293
});
292294
}

0 commit comments

Comments
 (0)