Skip to content

Commit

Permalink
Fixed #9747 - shiftKey invokes onRowSelect multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
cagataycivici committed Jan 11, 2021
1 parent 5630c0a commit 390af13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,18 +1091,19 @@ export class Table implements OnInit, AfterViewInit, AfterContentInit, Blockable
rangeEnd -= this.first;
}

let rangeRowsData = [];
for(let i = rangeStart; i <= rangeEnd; i++) {
let rangeRowData = this.filteredValue ? this.filteredValue[i] : this.value[i];
if (!this.isSelected(rangeRowData)) {
rangeRowsData.push(rangeRowData);
this._selection = [...this.selection, rangeRowData];
let dataKeyValue: string = this.dataKey ? String(ObjectUtils.resolveFieldData(rangeRowData, this.dataKey)) : null;
if (dataKeyValue) {
this.selectionKeys[dataKeyValue] = 1;
}
this.onRowSelect.emit({originalEvent: event, data: rangeRowData, type: 'row'});
}
}

this.onRowSelect.emit({originalEvent: event, data: rangeRowsData, type: 'row'});
this.selectionChange.emit(this.selection);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/showcase/components/table/tabledemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -3249,7 +3249,7 @@ <h3>Events</h3>
<tr>
<td>onRowSelect</td>
<td>event.originalEvent: Browser event <br>
event.data: Selected data <br >
event.data: Selected row data or an array if a range is selected with shift key <br >
event.type: Type of selection, valid values are "row", "radiobutton" and "checkbox"<br>
event.index: Index of the row
</td>
Expand Down

0 comments on commit 390af13

Please sign in to comment.