Skip to content

Commit 7e2aec4

Browse files
author
Olivier Dufour
committed
fix scroll bug with data table infinit width
1 parent 3147690 commit 7e2aec4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

addon/data-load.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ export class TableModel {
314314
this.scrolledHeight = 0;
315315
this.scrolledWidth = 0;
316316
this.editedRows = new Map();//idx to {cellidx: {dataEditValue:}, cellIdx2: {dataEditValue:}}
317+
this.state = {
318+
skipRecalculate: true
319+
};
317320
}
318321
setScrollerElement(scroller, scrolled) {
319322
this.scrolled = scrolled;
@@ -327,12 +330,16 @@ export class TableModel {
327330
&& this.offsetHeight == this.scroller.offsetHeight
328331
&& this.offsetWidth == this.scroller.offsetWidth
329332
) {
333+
this.state.skipRecalculate = true;
330334
return;
331335
}
332336
this.renderData({force: false});
333337
}
334338

335339
recalculate(){
340+
if (this.state.skipRecalculate) {
341+
return;
342+
}
336343
// Before this point we invalidate style and layout. After this point we recalculate style and layout, and we do not invalidate them again.
337344
if (this.rows.length > 0) {
338345
//thead
@@ -651,6 +658,7 @@ export class TableModel {
651658
this.rows = [];
652659
this.scrolledHeight = 0;
653660
this.scrolledWidth = 0;
661+
this.state.skipRecalculate = true;
654662
return;
655663
}
656664

@@ -659,11 +667,12 @@ export class TableModel {
659667
if (this.scrolledHeight != this.totalHeight || this.scrolledWidth != this.totalWidth){
660668
this.scrolledHeight = this.totalHeight;
661669
this.scrolledWidth = this.totalWidth;
670+
this.state.skipRecalculate = true;
662671
this.didUpdate();
663672
}
664673
return;
665674
}
666-
675+
this.state.skipRecalculate = false;
667676
while (this.firstRowTop < this.scrollTop - this.bufferHeight && this.firstRowIdx < this.rowCount - 1) {
668677
this.firstRowTop += this.rowVisible[this.firstRowIdx] * this.rowHeights[this.firstRowIdx];
669678
this.firstRowIdx++;
@@ -814,6 +823,7 @@ export class TableModel {
814823
this.editedRows = new Map();
815824
this.cellMenuOpened = null;
816825
this.cellMenuToClose = null;
826+
this.state.skipRecalculate = false;
817827
this.renderData({force: true});
818828
} else {
819829
// Data or visibility was changed
@@ -847,6 +857,7 @@ export class TableModel {
847857
}
848858
this.colVisible[c] = newVisible;
849859
}
860+
this.state.skipRecalculate = false;
850861
this.renderData({force: true});
851862
}
852863
}
@@ -1236,7 +1247,7 @@ export class ScrollTable extends React.Component {
12361247
}
12371248
componentDidUpdate() {
12381249
let {model} = this.props;
1239-
model.recalculate();
1250+
//model.recalculate();
12401251
}
12411252
render() {
12421253
let {model} = this.props;

0 commit comments

Comments
 (0)