From 4659e10188ae6e3d8ca524259aff5f4f7785394f Mon Sep 17 00:00:00 2001 From: Akshay Anand Date: Mon, 1 Mar 2021 21:31:42 -0500 Subject: [PATCH] fixes #733 --- src/components/Table.vue | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/Table.vue b/src/components/Table.vue index 1f85792c..b3e94fa8 100644 --- a/src/components/Table.vue +++ b/src/components/Table.vue @@ -1582,6 +1582,7 @@ export default { initializeSort() { const { enabled, initialSortBy, multipleColumns } = this.sortOptions; + const initSortBy = JSON.parse(JSON.stringify(initialSortBy)); if (typeof enabled === 'boolean') { this.sortable = enabled; @@ -1592,18 +1593,18 @@ export default { } //* initialSortBy can be an array or an object - if (typeof initialSortBy === 'object') { + if (typeof initSortBy === 'object') { const ref = this.fixedHeader ? this.$refs['table-header-secondary'] : this.$refs['table-header-primary']; - if (Array.isArray(initialSortBy)) { - ref.setInitialSort(initialSortBy); + if (Array.isArray(initSortBy)) { + ref.setInitialSort(initSortBy); } else { const hasField = Object.prototype.hasOwnProperty.call( - initialSortBy, + initSortBy, 'field' ); - if (hasField) ref.setInitialSort([initialSortBy]); + if (hasField) ref.setInitialSort([initSortBy]); } } },