-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored columnSorting plugin - stage 2 #5228
Conversation
sort(column, order) { | ||
this.setSortingColumn(column, order); | ||
sort(column, order = this.getNextOrderState(column)) { | ||
const allowSorting = this.hot.runHooks('beforeColumnSort', column, order); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to run a hook, even if a column is undefined
?
} | ||
} | ||
|
||
return ASC_SORT_STATE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use return
once? With the cached result in a variable.
@budnix mentioned that will be useful when we implement automatic code coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For discussion with @jansiegel. I will remember that.
const sortFunction = this.getSortFunctionForColumn(columnMeta); | ||
const visualColumn = this.hot.toVisualColumn(this.sortColumn); | ||
const columnMeta = this.hot.getCellMeta(0, visualColumn); | ||
const sortFunction = getSortFunctionForColumn(columnMeta); | ||
const emptyRows = this.hot.countEmptyRows(); | ||
let nrOfRows; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe nrOfRows
could be const
?
return column; | ||
}; | ||
|
||
const hot = handsontable({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use only handsontable({})
.
getPlugin('ColumnSorting').sort(0, 'asc'); | ||
|
||
// changing column order: 0 <-> 1 | ||
hot.updateSettings({modifyCol}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just updateSettings()
should be called in proper context.
const sortedColumn = this.$container.find('th span.columnSorting')[1]; | ||
const afterValue = window.getComputedStyle(sortedColumn, ':after').getPropertyValue('content'); | ||
|
||
expect(afterValue.indexOf(String.fromCharCode(9650))).toBeGreaterThan(-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can cache String.fromCharCode(9650)
once at a very beginning, with a comment, what char it should be.
…ing data when maxRows option is set #5064
Context
How has this been tested?
Manual tests on column sorting, including changing the order of columns.
Types of changes
Related issue(s):
Checklist: