Skip to content

Commit

Permalink
Fix bug in the sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyon147 committed Apr 25, 2022
1 parent e7efcec commit ab3cc7f
Show file tree
Hide file tree
Showing 4 changed files with 4,379 additions and 10 deletions.
4,372 changes: 4,371 additions & 1 deletion lib/polaris-vue.css

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions lib/polaris-vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2861,9 +2861,11 @@ exports.default = {
cellContentTypeClass: function cellContentTypeClass(index) {
return this.columnContentTypes && this.columnContentTypes[index] ? 'Polaris-DataTable__Cell--' + this.columnContentTypes[index] : '';
},
handleOnSort: function handleOnSort(index, direction) {
handleOnSort: function handleOnSort(index) {
var _this = this;

var direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

if (typeof index !== 'undefined' && this.sortable[index] === false) {
return;
}
Expand Down Expand Up @@ -10077,10 +10079,7 @@ var render = function() {
attrs: { scope: "col" },
on: {
click: function($event) {
return _vm.handleOnSort(
index,
_vm.defaultSortDirection
)
return _vm.handleOnSort(index)
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion lib/polaris-vue.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/components/PolarisDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
]"
class="Polaris-DataTable__Cell Polaris-DataTable__Cell--header"
scope="col"
@click="handleOnSort(index, defaultSortDirection)"
@click="handleOnSort(index)"
>
<div class="Polaris-DataTable__Heading">
<span class="Polaris-DataTable__Icon">
Expand Down Expand Up @@ -216,7 +216,7 @@ export default {
cellContentTypeClass(index) {
return this.columnContentTypes && this.columnContentTypes[index] ? 'Polaris-DataTable__Cell--' + this.columnContentTypes[index] : ''
},
handleOnSort(index, direction) {
handleOnSort(index, direction = null) {
if (typeof index !== 'undefined' && this.sortable[index] === false) {
return
}
Expand All @@ -225,7 +225,7 @@ export default {
// If we have a specific direction set (like on load) then use that.
if(direction){
this.sortedDirection = direction
}else if (this.sortedIndex === index){
} else if (this.sortedIndex === index){
// If we already have an index match then we need to flip the direction.
this.sortedDirection = this.sortedDirection === 'ascending' ? 'descending' : 'ascending'
} else {
Expand Down

0 comments on commit ab3cc7f

Please sign in to comment.