diff --git a/packages/react-bootstrap-table2/src/header-cell.js b/packages/react-bootstrap-table2/src/header-cell.js
index 79b4b9b..1270082 100644
--- a/packages/react-bootstrap-table2/src/header-cell.js
+++ b/packages/react-bootstrap-table2/src/header-cell.js
@@ -24,6 +24,7 @@ const HeaderCell = (props) => {
const {
text,
sort,
+ sortCaret,
filter,
filterRenderer,
headerTitle,
@@ -69,7 +70,7 @@ const HeaderCell = (props) => {
cellAttrs.className = cs(cellAttrs.className, 'sortable');
if (sorting) {
- sortSymbol = ;
+ sortSymbol = sortCaret ? sortCaret(sortOrder, column) : ;
// append customized classes or style if table was sorting based on the current column.
cellClasses = cs(
@@ -86,7 +87,7 @@ const HeaderCell = (props) => {
: headerSortingStyle
};
} else {
- sortSymbol = ;
+ sortSymbol = sortCaret ? sortCaret(undefined, column) : ;
}
}
@@ -151,6 +152,7 @@ HeaderCell.propTypes = {
onSort: PropTypes.func,
sorting: PropTypes.bool,
sortOrder: PropTypes.oneOf([Const.SORT_ASC, Const.SORT_DESC]),
+ sortCaret: PropTypes.func,
isLastSorting: PropTypes.bool,
onFilter: PropTypes.func,
onExternalFilter: PropTypes.func
diff --git a/packages/react-bootstrap-table2/test/header-cell.test.js b/packages/react-bootstrap-table2/test/header-cell.test.js
index 6814135..b0c4525 100644
--- a/packages/react-bootstrap-table2/test/header-cell.test.js
+++ b/packages/react-bootstrap-table2/test/header-cell.test.js
@@ -403,6 +403,24 @@ describe('HeaderCell', () => {
it('header should render SortSymbol as default', () => {
expect(wrapper.find(SortSymbol).length).toBe(1);
});
+
+ describe('when sortCaret is defined ', () => {
+ beforeEach(() => {
+ column = { ...column, sortCaret: jest.fn() };
+ wrapper = shallow(
+
+ );
+ });
+
+ it('header should not render SortSymbol', () => {
+ expect(wrapper.find(SortSymbol).length).toBe(0);
+ });
+
+ it('should call column.sortCaret correctly', () => {
+ expect(column.sortCaret).toHaveBeenCalledTimes(1);
+ expect(column.sortCaret).toHaveBeenCalledWith(undefined, column);
+ });
+ });
});
describe('and sorting prop is true', () => {
@@ -420,6 +438,30 @@ describe('HeaderCell', () => {
});
});
+ describe('when sortCaret is defined ', () => {
+ beforeEach(() => {
+ column = { ...column, sortCaret: jest.fn() };
+ wrapper = shallow(
+
+ );
+ });
+
+ it('header should not render SortSymbol', () => {
+ expect(wrapper.find(SortSymbol).length).toBe(0);
+ });
+
+ it('should call column.sortCaret correctly', () => {
+ expect(column.sortCaret).toHaveBeenCalledTimes(1);
+ expect(column.sortCaret).toHaveBeenCalledWith(Const.SORT_ASC, column);
+ });
+ });
+
describe('when headerSortingClasses is defined ', () => {
const classes = 'foo';
const order = Const.SORT_DESC;