diff --git a/packages/table/src/store/helper.js b/packages/table/src/store/helper.js index 81d73f6042..b27ee896bc 100644 --- a/packages/table/src/store/helper.js +++ b/packages/table/src/store/helper.js @@ -1,4 +1,5 @@ import Store from './index'; +import debounce from 'throttle-debounce/debounce'; export function createStore(table, initialState = {}) { if (!table) { @@ -7,6 +8,9 @@ export function createStore(table, initialState = {}) { const store = new Store(); store.table = table; + // fix https://github.com/ElemeFE/element/issues/14075 + // related pr https://github.com/ElemeFE/element/pull/14146 + store.toggleAllSelection = debounce(10, store._toggleAllSelection); Object.keys(initialState).forEach(key => { store.states[key] = initialState[key]; }); diff --git a/packages/table/src/store/watcher.js b/packages/table/src/store/watcher.js index c657f25916..641655b39a 100644 --- a/packages/table/src/store/watcher.js +++ b/packages/table/src/store/watcher.js @@ -1,5 +1,4 @@ import Vue from 'vue'; -import debounce from 'throttle-debounce/debounce'; import merge from 'element-ui/src/utils/merge'; import { getKeysMap, getRowIdentity, getColumnById, getColumnByKey, orderBy, toggleRowStatus } from '../util'; import expand from './expand'; @@ -168,7 +167,7 @@ export default Vue.extend({ } }, - toggleAllSelection: debounce(10, function() { + _toggleAllSelection() { const states = this.states; const { data = [], selection } = states; // when only some rows are selected (but not all), select or deselect all of them @@ -195,7 +194,7 @@ export default Vue.extend({ this.table.$emit('selection-change', selection ? selection.slice() : []); } this.table.$emit('select-all', selection); - }), + }, updateSelectionByRowKey() { const states = this.states;