-
Notifications
You must be signed in to change notification settings - Fork 380
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
fix(react-grid): correlate sorting order with grouping order #414
Conversation
]; | ||
let nextSorting = []; | ||
if (keepOther === true) { | ||
nextSorting = sorting.slice(); |
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.
Check case when seamless immutable is used. Probably, sorting.slice()
should be replaced to Array.from
.
this.cancelGroupingChange = this.applyReducer.bind(this, cancelGroupingChange); | ||
this.setColumnSorting = this.setColumnSorting.bind(this); | ||
} | ||
getState() { |
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.
It's strange that 'get' function creates a new object on each call.
this.setState(nextState); | ||
|
||
const { onGroupingChange } = this.props; | ||
if (onGroupingChange && nextState.grouping !== state.grouping) { |
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.
nextState.grouping
, nextState.expandedGroups
can be replaced to const { grouping, expandedGroups } = nextState;
@@ -64,7 +64,7 @@ tableHeaderRows | Getter | Array<[TableRow](table-view.md#table-row)> | He | |||
sorting | Getter | Array<[Sorting](sorting-state.md#sorting)> | Column sorting. | |||
columns | Getter | Array<[Column](#column)> | Table columns. | |||
grouping | Getter | Array<[Grouping](grouping-state.md#grouping)> | Columns used for grouping. | |||
setColumnSorting | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean, cancel: boolean }) => void | Changes column sorting. | |||
setColumnSorting | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean | Array<String>, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be keeped when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`. |
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.
keeped => kept
{ columnName: 'test', direction: 'asc' }, | ||
{ columnName: 'test3', direction: 'asc' }, | ||
]); | ||
it('should set corretct sorting if sortIndex is specified', () => { |
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.
Typo: 'corretct'
@@ -89,7 +89,7 @@ columns | Getter | Array<[Column](#column)> | Grid columns. | |||
draftGrouping | Getter | Array<[DraftGrouping](grouping-state.md#draft-grouping)> | Grouping options used for the preview. | |||
sorting | Getter | Array<[Sorting](sorting-state.md#sorting)> | The current sorting state. | |||
groupByColumn | Action | ({ columnName: string }) => void | Toggles a column's grouping state. | |||
setColumnSorting | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean, cancel: boolean }) => void | Updates column sorting. | |||
setColumnSorting | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean | Array<String>, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be kept when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`. |
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.
Please check this sentence
The
keepOther
can handle contains the names...
@@ -55,6 +55,8 @@ A string value that consists of values by which rows are grouped, separated by t | |||
Name | Plugin | Type | Description | |||
-----|--------|------|------------ | |||
columns | Getter | Array<[Column](grid.md#column)> | The grid columns. | |||
sorting? | Getter | Array<[Sorting](sorting-state.md#sorting)> | Applied column sorting. | |||
setColumnSorting? | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean | Array<String>, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be kept when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`. |
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.
can handle contains
@@ -40,4 +40,4 @@ none | |||
Name | Plugin | Type | Description | |||
-----|--------|------|------------ | |||
sorting | Getter | Array<[Sorting](#sorting)> | Applied column sorting. | |||
setColumnSorting | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean, cancel: boolean, scope: Array<String> }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. Cancels sorting by the current column if `cancel` is set to `true`. The `scope` array contains the names of columns taken into account when sorting. | |||
setColumnSorting | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean | Array<String>, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be kept when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`. |
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.
can handle contains
@@ -64,7 +64,7 @@ tableHeaderRows | Getter | Array<[TableRow](table-view.md#table-row)> | He | |||
sorting | Getter | Array<[Sorting](sorting-state.md#sorting)> | Column sorting. | |||
columns | Getter | Array<[Column](#column)> | Table columns. | |||
grouping | Getter | Array<[Grouping](grouping-state.md#grouping)> | Columns used for grouping. | |||
setColumnSorting | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean, cancel: boolean }) => void | Changes column sorting. | |||
setColumnSorting | Action | ({ columnName: string, direction: 'asc' | 'desc', keepOther: boolean | Array<String>, cancel: boolean }) => void | Changes a column's sort direction. Keeps existing sorting if `keepOther` is set to `true`. The `keepOther` can handle contains the names of columns will be kept when sorting is applied. Cancels sorting by the current column if `cancel` is set to `true`. |
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.
can handle contains
expect(defaultDeps.action.setCurrentPage.mock.calls) | ||
.toEqual([[2]]); | ||
expect(defaultDeps.action.setCurrentPage.mock.calls[0][0]) | ||
.toEqual(2); |
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.
Why not use the .toHaveBeenCalledWith()
matcher?
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.
Action is called with additional arguments (getters and actions)
fixes #398
BREAKING CHANGES:
The
scope
parameter of thesetColumnSorting
action has been removedThe
GroupingState
plugin now has an optional dependency on theSortingState
plugin. So,GroupingState
should be placed afterSortingState
.Before:
After: