[ADF-2529] click will unselect the selected row (#3188)

* [ADF-2529] click will unselect the selected row

* [ADF-2529] removed wrong comment
This commit is contained in:
Vito
2018-04-18 12:28:21 +01:00
committed by Denys Vuika
parent 5e5b0a9207
commit 5cd554e85e
2 changed files with 9 additions and 1 deletions

View File

@@ -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], <any> { metaKey: true, preventDefault() {} });
expect(rows[0].isSelected).toBeTruthy();
dataTable.onRowClick(rows[0], <any> { metaKey: true, preventDefault() {} });

View File

@@ -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) {