Skip to content

Commit 529ef5c

Browse files
committed
Tables sorting update
1 parent 57d29e2 commit 529ef5c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/Administration/Users/UsersList/UsersList.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ const UsersList = ({ match }) => {
114114

115115
const handelChangeOrder = (event, columnId) => {
116116
setOrder({
117-
order: order.order === 'asc' ? 'desc' : 'asc',
117+
// If the sorting column has changed
118+
order: columnId !== order.orderBy || order.order === 'desc' ? 'asc' : 'desc',
118119
orderBy: columnId,
119120
})
120121
}
@@ -138,13 +139,18 @@ const UsersList = ({ match }) => {
138139
<TableRow>
139140
{tableColumns.map(column => (
140141
<TableCell key={column.id}>
141-
<TableSortLabel
142-
active={order.orderBy === column.id}
143-
direction={order.orderBy === column.id ? order.order : 'asc'}
144-
onClick={event => handelChangeOrder(event, column.id)}
145-
>
146-
{column.label}
147-
</TableSortLabel>
142+
{/* Sortable */}
143+
{column.isSortable && (
144+
<TableSortLabel
145+
active={order.orderBy === column.id}
146+
direction={order.orderBy === column.id ? order.order : 'asc'}
147+
onClick={event => handelChangeOrder(event, column.id)}
148+
>
149+
{column.label}
150+
</TableSortLabel>
151+
)}
152+
{/* Non-sortable */}
153+
{!column.isSortable && column.label}
148154
</TableCell>
149155
))}
150156
<TableCell>Actions</TableCell>

0 commit comments

Comments
 (0)