Skip to content

Commit

Permalink
Fixed #2923 - Frozen columns and non-frozen columns can be reordered …
Browse files Browse the repository at this point in the history
…with each other in DataTable
  • Loading branch information
mertsincan committed May 25, 2022
1 parent c922d43 commit 265d7e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions components/lib/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export const DataTable = React.forwardRef((props, ref) => {

const { originalEvent: event, column } = e;

if (props.reorderableColumns && getColumnProp(column, 'reorderable') !== false) {
if (props.reorderableColumns && getColumnProp(column, 'reorderable') !== false && !getColumnProp(column, 'frozen')) {
if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA' || DomHandler.hasClass(event.target, 'p-column-resizer'))
event.currentTarget.draggable = false;
else
Expand Down Expand Up @@ -616,9 +616,9 @@ export const DataTable = React.forwardRef((props, ref) => {
}

const onColumnHeaderDragOver = (e) => {
const { originalEvent: event } = e;
const { originalEvent: event, column } = e;
const dropHeader = findParentHeader(event.currentTarget);
if (props.reorderableColumns && draggedColumnElement.current && dropHeader) {
if (props.reorderableColumns && draggedColumnElement.current && dropHeader && !getColumnProp(column, 'frozen')) {
event.preventDefault();

if (draggedColumnElement.current !== dropHeader) {
Expand Down
5 changes: 3 additions & 2 deletions components/lib/datatable/HeaderCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,15 @@ export const HeaderCell = React.memo((props) => {
const sortMeta = getSortMeta();
const style = getStyle();
const align = getColumnProp('alignHeader') || getColumnProp('align');
const frozen = getColumnProp('frozen');
const className = classNames(getColumnProp('headerClassName'), getColumnProp('className'), {
'p-sortable-column': getColumnProp('sortable'),
'p-resizable-column': props.resizableColumns && getColumnProp('resizeable'),
'p-highlight': sortMeta.sorted,
'p-frozen-column': getColumnProp('frozen'),
'p-frozen-column': frozen,
'p-selection-column': getColumnProp('selectionMode'),
'p-sortable-disabled': getColumnProp('sortable') && _isSortableDisabled,
'p-reorderable-column': props.reorderableColumns && getColumnProp('reorderable'),
'p-reorderable-column': props.reorderableColumns && getColumnProp('reorderable') && !frozen,
[`p-align-${align}`]: !!align
});
const tabIndex = getColumnProp('sortable') && !_isSortableDisabled ? props.tabIndex : null;
Expand Down

0 comments on commit 265d7e4

Please sign in to comment.