Skip to content

Commit

Permalink
Fix sorting icon issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Spens committed Oct 31, 2016
1 parent c3369ee commit 6b81af8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib/Table/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component, PropTypes } from 'react';
import propTypes from './propTypes';
import Pagination from '../Pagination';
import { getSortableIcon } from './utils';

export default class Table extends Component {
static defaultProps = {
Expand Down Expand Up @@ -36,10 +37,15 @@ export default class Table extends Component {
{name}
<span
style={this.context.theme.tableColumnHeaderDirection}
dangerouslySetInnerHTML={{ __html: this.props.sortable.includes(id) && this.props.sort !== id && '&#8645;' }}
>
{/* {this.props.sortable.includes(id) && this.props.sort !== id && '&#8645;'} */}
</span>
dangerouslySetInnerHTML={{
__html: getSortableIcon({
sortableColumns: this.props.sortable,
sortedColumn: this.props.sort,
columnId: id,
sortDirection: this.props.direction
})
}}
></span>
</th>
))}
</tr>
Expand Down
6 changes: 6 additions & 0 deletions src/lib/Table/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const getSortableIcon = ({ sortableColumns, sortedColumn, columnId, sortDirection }) => {
if (!sortableColumns.includes(columnId)) return;
if (sortedColumn !== columnId) return '&#8645;';
if (sortDirection === 'ASC') return '&#8593;';
if (sortDirection === 'DESC') return '&#8595;';
}

0 comments on commit 6b81af8

Please sign in to comment.