-
Notifications
You must be signed in to change notification settings - Fork 47
Description
The logic in DataTableRow unselects the row when it is being destroyed. This causes spurious row selection events with nulls.
| this.selected = false; |
export class DataTableRow implements OnDestroy {
// ..
ngOnDestroy() {
this.selected = false;
}
// ..
}
This causes the DataTableRow.selectedChange EventEmitter fire:
| this.selectedChange.emit(selected); |
set selected(selected) {
this._selected = selected;
this.selectedChange.emit(selected);
}
This behavior causes spurious row selection events to be fired in case the component hosting the grid is being destroyed.
This is problematic, in case the grid selection is used somewhere else as well, outside of the component hosting the grid.
For example you could have a case, where you implement the grid to select something and then the selection is used on another screen. The grid selection is stored in a dedicated service external to the component, to be used for the next step of a wizard.
When the component used to host the grid is being destroyed, the grid fires DataTableRow.selectedChange with null.
By default, the listener cannot distinguish if the un-selection was performed by the user, by un-selecting the previously selected item, or by the grid row destruction logic.