Skip to content

Commit

Permalink
Refactor #1942
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Apr 6, 2021
1 parent 89c4855 commit 1df9618
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/components/datatable/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export class TableBody extends Component {
const allowCheckboxRowSelection = this.isCheckboxSelectionMode() && !this.isCheckboxRowSelectionMode();

if (this.props.selectionMode || allowRadioRowSelection || allowCheckboxRowSelection) {
if (this.isMultipleSelectionMode() && event.originalEvent.shiftKey && this.anchorRowIndex !== null) {
if ((this.isMultipleSelectionMode() || allowCheckboxRowSelection) && event.originalEvent.shiftKey && this.anchorRowIndex !== null) {
this.onRangeSelection(event);
}
else {
let metaKey = this.rowTouched && this.props.metaKeySelection && (event.originalEvent.metaKey || event.originalEvent.ctrlKey);
let metaKey = !this.rowTouched && this.props.metaKeySelection && (event.originalEvent.metaKey || event.originalEvent.ctrlKey);
this.anchorRowIndex = event.index;
this.rangeRowIndex = event.index;
this.anchorRowFirst = this.props.first;
Expand Down Expand Up @@ -75,7 +75,7 @@ export class TableBody extends Component {
this.onRangeSelection(event);
}
else {
let metaKey = this.rowTouched && this.props.metaKeySelection && (event.originalEvent.metaKey || event.originalEvent.ctrlKey);
let metaKey = !this.rowTouched && this.props.metaKeySelection && (event.originalEvent.metaKey || event.originalEvent.ctrlKey);
let { originalEvent, ...data } = event;
this.anchorRowIndex = event.rowIndex;
this.rangeRowIndex = event.rowIndex;
Expand Down Expand Up @@ -130,7 +130,13 @@ export class TableBody extends Component {
this.anchorRowIndex = this.rangeRowIndex;
this.anchorCellIndex = event.cellIndex;

if (target) {
if (this.isCheckboxSelectionMode() && !this.props.cellSelection) {
const checkbox = DomHandler.findSingle(target, 'td.p-selection-column .p-checkbox-box');
if (checkbox) {
checkbox.focus();
}
}
else if (target) {
target.focus();
}
}
Expand Down

0 comments on commit 1df9618

Please sign in to comment.