Skip to content

Commit cbd001e

Browse files
authored
Merge pull request #1232 from nasa/open1216
[Tables] Fixed table scroll by modifying selection of scrollable element. Fixes #1216
2 parents 8a00181 + bff4e12 commit cbd001e

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
define(
3-
[],
4-
function () {
3+
['zepto'],
4+
function ($) {
55

66
/**
77
* A controller for the MCTTable directive. Populates scope with
@@ -16,13 +16,13 @@ define(
1616
var self = this;
1717

1818
this.$scope = $scope;
19-
this.element = element;
19+
this.element = $(element[0]);
2020
this.$timeout = $timeout;
2121
this.maxDisplayRows = 50;
2222

23-
this.scrollable = element.find('div');
24-
this.thead = element.find('thead');
25-
this.tbody = element.find('tbody');
23+
this.scrollable = this.element.find('.l-view-section.scrolling').first();
24+
this.resultsHeader = this.element.find('.mct-table>thead').first();
25+
this.sizingTableBody = this.element.find('.sizing-table>tbody').first();
2626
this.$scope.sizingRow = {};
2727

2828
this.scrollable.on('scroll', this.onScroll.bind(this));
@@ -261,8 +261,8 @@ define(
261261
* for individual rows.
262262
*/
263263
MCTTableController.prototype.setElementSizes = function () {
264-
var thead = this.thead,
265-
tbody = this.tbody,
264+
var thead = this.resultsHeader,
265+
tbody = this.sizingTableBody,
266266
firstRow = tbody.find('tr'),
267267
column = firstRow.find('td'),
268268
headerHeight = thead.prop('offsetHeight'),

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

+9-14
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@
2222

2323
define(
2424
[
25+
"zepto",
2526
"../../src/controllers/MCTTableController"
2627
],
27-
function (MCTTableController) {
28+
function ($, MCTTableController) {
29+
30+
var MOCK_ELEMENT_TEMPLATE =
31+
'<div><div class="l-view-section scrolling">' +
32+
'<table class="sizing-table"><tbody></tbody></table>' +
33+
'<table class="mct-table"><thead></thead></table>' +
34+
'</div></div>';
2835

2936
describe('The MCTTable Controller', function () {
3037

@@ -55,19 +62,7 @@ define(
5562
watches[event] = callback;
5663
});
5764

58-
mockElement = jasmine.createSpyObj('element', [
59-
'find',
60-
'prop',
61-
'on'
62-
]);
63-
mockElement.find.andReturn(mockElement);
64-
mockElement.prop.andReturn(0);
65-
mockElement[0] = {
66-
scrollTop: 0,
67-
scrollHeight: 500,
68-
offsetHeight: 1000
69-
};
70-
65+
mockElement = $(MOCK_ELEMENT_TEMPLATE);
7166
mockExportService = jasmine.createSpyObj('exportService', [
7267
'exportCSV'
7368
]);

0 commit comments

Comments
 (0)