Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grid): Correct shift-click selection in grouped IgxGrid #13757 #13785

Merged
merged 19 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
14edc91
fix(grid): Correct shift-click selection in grouped IgxGrid #13757
valeriatoneva Jan 6, 2024
aa9329c
Merge branch 'master' into valeriatoneva/fix-13757-master
valeriatoneva Jan 8, 2024
b4370e8
Merge branch 'master' into valeriatoneva/fix-13757-master
hanastasov Jan 10, 2024
b397b71
fix(grid): Added conditional checks and enchanced comparison function
valeriatoneva Jan 10, 2024
0295d6d
Merge remote-tracking branch 'origin/valeriatoneva/fix-13757-master' …
valeriatoneva Jan 11, 2024
d696bb9
fix(grid): Taking into account duplicate rows
valeriatoneva Jan 11, 2024
f608be8
fix(grid): Fixed indexing on non-grouped selection
valeriatoneva Jan 12, 2024
98c7dae
fix(grid): Returned previous code and made a slight change
valeriatoneva Jan 15, 2024
88eb7c2
Merge branch 'master' into valeriatoneva/fix-13757-master
hanastasov Jan 15, 2024
2bedbf1
fix(grid): Formated and cleared code
valeriatoneva Jan 16, 2024
774d460
fix(grid): Formated and cleared code
valeriatoneva Jan 16, 2024
18914dd
fix(grid): Removed white spaces
valeriatoneva Jan 16, 2024
2900601
fix(grid): Removed white spaces
valeriatoneva Jan 16, 2024
628e621
fix(grid): Cleared package-lock.json
valeriatoneva Jan 16, 2024
a4ccc6d
test(grid): Added unit test for shift-click row selection with grouping
valeriatoneva Jan 17, 2024
0ae7b31
style(grid): Removing whitespaces and formating
valeriatoneva Jan 17, 2024
8069fee
style(grid): Correct minor typos
valeriatoneva Jan 17, 2024
b04477e
Merge branch 'master' into valeriatoneva/fix-13757-master
hanastasov Jan 22, 2024
f0bb117
Merge branch 'master' into valeriatoneva/fix-13757-master
ddincheva Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,53 @@ describe('IgxGrid - Row Selection #grid', () => {
}
});

it('Should select the correct rows with Shift + Click when grouping is activated', () => {
expect(grid.selectRowOnClick).toBe(true);
spyOn(grid.rowSelectionChanging, 'emit').and.callThrough();

grid.groupBy({
fieldName: 'ProductName', dir: SortingDirection.Desc, ignoreCase: false
});

fix.detectChanges();

const firstGroupRow = grid.gridAPI.get_row_by_index(1);
const lastGroupRow = grid.gridAPI.get_row_by_index(4);

// Clicking on the first row within a group
UIInteractions.simulateClickEvent(firstGroupRow.nativeElement);
fix.detectChanges();

GridSelectionFunctions.verifyRowSelected(firstGroupRow);

// Simulate Shift+Click on a row within another group
const mockEvent = new MouseEvent('click', { shiftKey: true });
lastGroupRow.nativeElement.dispatchEvent(mockEvent);
fix.detectChanges();

expect(grid.selectedRows).toEqual([5, 14, 8]); // ids
expect(grid.rowSelectionChanging.emit).toHaveBeenCalledTimes(2);
expect(grid.rowSelectionChanging.emit).toHaveBeenCalledWith({
added: [grid.dataView[2], grid.dataView[4]],
cancel: false,
event: jasmine.anything(),
newSelection: [grid.dataView[1], grid.dataView[2], grid.dataView[4]],
oldSelection: [grid.dataView[1]],
removed: [],
allRowsSelected: false,
owner: grid
});

const expectedSelectedRowIds = [5, 14, 8];
grid.dataView.forEach((rowData, index) => {
if (expectedSelectedRowIds.includes(rowData.ProductID)) {
const row = grid.gridAPI.get_row_by_index(index);
GridSelectionFunctions.verifyRowSelected(row);
}
});

});

it('Should NOT select multiple rows with Shift + Click when selectRowOnClick has false value', () => {
grid.selectRowOnClick = false;
spyOn(grid.rowSelectionChanging, 'emit').and.callThrough();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ export class IgxGridSelectionService {
/** Returns all data in the grid, with applied filtering and sorting and without deleted rows. */
public get allData(): Array<any> {
let allData;
if (this.isFilteringApplied() || this.grid.sortingExpressions.length) {
// V.T. Jan 17th, 2024 #13757 Adding an additional conditional check to take account WITHIN range of groups
if (this.isFilteringApplied() || this.grid.sortingExpressions.length || this.grid.groupingExpressions?.length) {
allData = this.grid.pinnedRecordsCount ? this.grid._filteredSortedUnpinnedData : this.grid.filteredSortedData;
} else {
allData = this.grid.gridAPI.get_all_data(true);
Expand Down
Loading