mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-8663] Fixed issue where datatable selection was not getting reset completely in some cases (#10136)
* [ACS-8663] Fixed issue where datatable selection was not getting reset completely in some cases * [ACS-8663] Updated unit tests
This commit is contained in:
@@ -423,6 +423,7 @@ describe('DataTable', () => {
|
|||||||
describe('Selection reset', () => {
|
describe('Selection reset', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
spyOn(dataTable, 'resetSelection').and.callThrough();
|
spyOn(dataTable, 'resetSelection').and.callThrough();
|
||||||
|
spyOn(dataTable.selectedItemsCountChanged, 'emit');
|
||||||
|
|
||||||
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
dataTable.data = new ObjectDataTableAdapter([{ name: '1' }, { name: '2' }], [new ObjectDataColumn({ key: 'name' })]);
|
||||||
const rows = dataTable.data.getRows();
|
const rows = dataTable.data.getRows();
|
||||||
@@ -440,6 +441,9 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(dataTable.selection).toEqual([]);
|
expect(dataTable.selection).toEqual([]);
|
||||||
|
expect(dataTable.selectedItemsCountChanged.emit).toHaveBeenCalledWith(0);
|
||||||
|
expect(dataTable.isSelectAllIndeterminate).toBe(false);
|
||||||
|
expect(dataTable.isSelectAllChecked).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset selection on multiselect change', () => {
|
it('should reset selection on multiselect change', () => {
|
||||||
@@ -448,6 +452,9 @@ describe('DataTable', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(dataTable.selection).toEqual([]);
|
expect(dataTable.selection).toEqual([]);
|
||||||
|
expect(dataTable.selectedItemsCountChanged.emit).toHaveBeenCalledWith(0);
|
||||||
|
expect(dataTable.isSelectAllIndeterminate).toBe(false);
|
||||||
|
expect(dataTable.isSelectAllChecked).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -943,7 +950,7 @@ describe('DataTable', () => {
|
|||||||
const event = new MouseEvent('click');
|
const event = new MouseEvent('click');
|
||||||
Object.defineProperty(event, 'target', {
|
Object.defineProperty(event, 'target', {
|
||||||
value: {
|
value: {
|
||||||
getAttribute: (attr: string) => attr === 'data-adf-datatable-row-checkbox' ? 'data-adf-datatable-row-checkbox' : null,
|
getAttribute: (attr: string) => (attr === 'data-adf-datatable-row-checkbox' ? 'data-adf-datatable-row-checkbox' : null),
|
||||||
hasAttribute: (attr: string) => attr === 'data-adf-datatable-row-checkbox',
|
hasAttribute: (attr: string) => attr === 'data-adf-datatable-row-checkbox',
|
||||||
closest: () => null
|
closest: () => null
|
||||||
}
|
}
|
||||||
|
@@ -619,6 +619,8 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
|
|||||||
this.selection = [];
|
this.selection = [];
|
||||||
}
|
}
|
||||||
this.isSelectAllChecked = false;
|
this.isSelectAllChecked = false;
|
||||||
|
this.isSelectAllIndeterminate = false;
|
||||||
|
this.selectedItemsCountChanged.emit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
onRowDblClick(row: DataRow, event?: Event) {
|
onRowDblClick(row: DataRow, event?: Event) {
|
||||||
|
Reference in New Issue
Block a user