Skip to content

Commit

Permalink
Merge pull request #693 from contember/fix/datagrid-sorting
Browse files Browse the repository at this point in the history
fix(react-datagrid-ui): fix disabled sorting
  • Loading branch information
matej21 authored Apr 24, 2024
2 parents 9918ebe + 93da54e commit 02dc70a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type DataGridHeaderCellProps =
export function DataGridHeaderCell(props: DataGridHeaderCellProps): ReactElement {
const {
columnKey,
column: { header, headerJustification, justification, shrunk, ascOrderIcon, descOrderIcon },
column: { header, headerJustification, justification, shrunk, ascOrderIcon, descOrderIcon, enableOrdering },
} = props
const orderDirections = useDataViewSortingState().directions
const { setOrderBy } = useDataViewSortingMethods()
Expand All @@ -36,7 +36,12 @@ export function DataGridHeaderCell(props: DataGridHeaderCellProps): ReactElement
return (
<TableHeaderCell scope="col" justification={headerJustification || justification} shrunk={shrunk}>
<span style={{ display: 'flex', justifyContent: 'flex-start', gap: '.25em' }}>
<span onClick={e => setOrderBy(columnKey, 'next', e.ctrlKey || e.metaKey)} style={{ cursor: 'pointer' }}>
<span onClick={e => {
if (enableOrdering === false) {
return
}
return setOrderBy(columnKey, 'next', e.ctrlKey || e.metaKey)
}} style={{ cursor: 'pointer' }}>
{header}
&nbsp;
{orderState &&
Expand Down

0 comments on commit 02dc70a

Please sign in to comment.