Bug #35904
closed
mgr/dashboard: ngOnChanges function is executing without any change on table component
Added by Kanika Murarka over 5 years ago.
Updated about 3 years ago.
Description
`ngOnChanges` function is triggered even when there is no change in selection (checked in `cd-table-key-value` component). Also, it triggers automatically after every particular interval.
This can be easily fixed with
--- src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts (date 1536569186000)
+++ src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts (date 1536578794000)
@@ -384,8 +384,8 @@
/**
* After updating the data, we have to update the selected items
- * because details may have changed,
- * or some selected items may have been removed.
+ * because details may have changed, or some selected items may
+ * have been removed.
*/
updateSelected() {
const newSelected = [];
@@ -396,8 +396,12 @@
}
}
});
- this.selection.selected = newSelected;
- this.onSelect();
+ if (!_.isEqual(this.selection.selected, newSelected)) {
+ this.selection.selected = newSelected;
+ this.onSelect();
+ }
}
onSelect() {
!!! Attention !!!
Applying this code will prevent the updating of the details pages as they are implemented right at the moment, so we will have a regression here. Keep in mind that the data of the selected object might have changed in the meanwhile. Because of this behaviour the 'updateSelected' method is implemented that way to allow our details pages to get notified of data changes and to redraw the information. Currently i do not have any idea how to workaround this.
- Status changed from New to In Progress
- Subject changed from mgr/dashboard: ngOnChanges function is executing without any change to mgr/dashboard: ngOnChanges function is executing without any change on table component
- Status changed from In Progress to Fix Under Review
- Status changed from Fix Under Review to Resolved
- % Done changed from 0 to 100
- Project changed from mgr to Dashboard
Also available in: Atom
PDF