Skip to content
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(DataTable): return correct sort direction in sort action callback #8048

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions packages/react/src/components/DataTable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,18 @@ export default class DataTable extends React.Component {
sortDirection,
isSortable,
isSortHeader: sortHeaderKey === header.key,
// Compose the event handlers so we don't overwrite a consumer's `onClick`
// handler
onClick: composeEventHandlers([
this.handleSortBy(header.key),
onClick
? this.handleOnHeaderClick(onClick, {
onClick: (event) => {
const nextSortState = getNextSortState(this.props, this.state, {
key: header.key,
});
this.setState(nextSortState, () => {
onClick &&
this.handleOnHeaderClick(onClick, {
sortHeaderKey: header.key,
sortDirection,
})
: null,
]),
sortDirection: nextSortState.sortDirection,
})(event);
});
},
};
};

Expand Down