diff --git a/lib/core/datatable/components/datatable/datatable.component.spec.ts b/lib/core/datatable/components/datatable/datatable.component.spec.ts index 74bf3b050f..7f8ffd8096 100644 --- a/lib/core/datatable/components/datatable/datatable.component.spec.ts +++ b/lib/core/datatable/components/datatable/datatable.component.spec.ts @@ -312,6 +312,9 @@ describe('DataTable', () => { expect(rows[0].isSelected).toBeTruthy(); dataTable.onRowClick(rows[0], null); + expect(rows[0].isSelected).toBeFalsy(); + + dataTable.onRowClick(rows[0], { metaKey: true, preventDefault() {} }); expect(rows[0].isSelected).toBeTruthy(); dataTable.onRowClick(rows[0], { metaKey: true, preventDefault() {} }); diff --git a/lib/core/datatable/components/datatable/datatable.component.ts b/lib/core/datatable/components/datatable/datatable.component.ts index 7475509ef2..e642853037 100644 --- a/lib/core/datatable/components/datatable/datatable.component.ts +++ b/lib/core/datatable/components/datatable/datatable.component.ts @@ -317,7 +317,12 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck if (this.isMultiSelectionMode()) { const modifier = e && (e.metaKey || e.ctrlKey); - const newValue = modifier ? !row.isSelected : true; + let newValue: boolean; + if (this.selection.length === 1) { + newValue = !row.isSelected; + } else { + newValue = modifier ? !row.isSelected : true; + } const domEventName = newValue ? 'row-select' : 'row-unselect'; if (!modifier) {