Skip to content

Commit 116c6e5

Browse files
committed
Merge pull request nasa#918 from nasa/rt-updates-910
[Table] Remove length check when updating visible rows
2 parents a39ce56 + c448753 commit 116c6e5

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

platform/features/table/src/controllers/MCTTableController.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,8 @@ define(
165165

166166
//No need to scroll
167167
if (this.$scope.displayRows.length < this.maxDisplayRows) {
168-
//Check whether need to resynchronize visible with display
169-
// rows (if data added)
170-
if (this.$scope.visibleRows.length !==
171-
this.$scope.displayRows.length){
172-
start = 0;
173-
end = this.$scope.displayRows.length;
174-
} else {
175-
//Data is in sync, and no need to calculate scroll,
176-
// so do nothing.
177-
return;
178-
}
168+
start = 0;
169+
end = this.$scope.displayRows.length;
179170
} else {
180171
//rows has exceeded display maximum, so may be necessary to
181172
// scroll

platform/features/table/test/controllers/MCTTableControllerSpec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ define(
6161
]);
6262
mockElement.find.andReturn(mockElement);
6363
mockElement.prop.andReturn(0);
64+
mockElement[0] = {
65+
scrollTop: 0,
66+
scrollHeight: 500,
67+
offsetHeight: 1000
68+
};
6469

6570
mockScope.displayHeaders = true;
6671
mockTimeout = jasmine.createSpy('$timeout');
6772
mockTimeout.andReturn(promise(undefined));
6873

6974
controller = new MCTTableController(mockScope, mockTimeout, mockElement);
70-
spyOn(controller, 'setVisibleRows');
75+
spyOn(controller, 'setVisibleRows').andCallThrough();
7176
});
7277

7378
it('Reacts to changes to filters, headers, and rows', function() {
@@ -178,6 +183,16 @@ define(
178183
expect(sortedRows[2].col2.text).toEqual('abc');
179184
});
180185

186+
// https://github.com/nasa/openmct/issues/910
187+
it('updates visible rows in scope', function () {
188+
var oldRows;
189+
mockScope.rows = testRows;
190+
controller.setRows(testRows);
191+
oldRows = mockScope.visibleRows;
192+
mockScope.toggleSort('col2');
193+
expect(mockScope.visibleRows).not.toEqual(oldRows);
194+
});
195+
181196
it('correctly sorts rows of differing types', function () {
182197
mockScope.sortColumn = 'col2';
183198
mockScope.sortDirection = 'desc';

0 commit comments

Comments
 (0)