From 2248053b096a48a6a3d68f1538e8d57f3069a488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Sadzi=C5=84ski?= Date: Wed, 9 Nov 2022 16:03:26 +0100 Subject: [PATCH] (core) Fixing scrolling for linked sections Summary: When a grid is scrolled, and then data is changed (due to click in a linked section), some records are not rendered, or position of the scroll container is corrupted Test Plan: Added Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D3661 --- app/client/lib/koDomScrolly.js | 24 +++++++++++++----------- test/fixtures/docs/Teams.grist | Bin 0 -> 192512 bytes 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 test/fixtures/docs/Teams.grist diff --git a/app/client/lib/koDomScrolly.js b/app/client/lib/koDomScrolly.js index 8803de27..ad708927 100644 --- a/app/client/lib/koDomScrolly.js +++ b/app/client/lib/koDomScrolly.js @@ -297,8 +297,7 @@ Scrolly.prototype.updateSize = function() { this.numRendered = numVisible + 2 * this.numBuffered; // Re-render everything. - this.begin = gutil.clamp(this.begin, 0, this.numRows - this.numRendered); - this.end = gutil.clamp(this.begin + this.numRendered, 0, this.numRows); + this._updateRange(); this.render(); this.syncScrollPosition(); }; @@ -333,10 +332,7 @@ Scrolly.prototype.scrollTo = function(top) { // just particularly easy to come across. var atEnd = (top + this.shownHeight >= this.panes[0].container.scrollHeight); - var rowAtScrollTop = this.rowOffsetTree.getIndex(top); - this.begin = gutil.clamp(rowAtScrollTop - this.numBuffered, 0, this.numRows - this.numRendered); - this.end = gutil.clamp(this.begin + this.numRendered, 0, this.numRows); - + this._updateRange(); // Do the magic. this.render(); @@ -367,11 +363,7 @@ Scrolly.prototype.onDataSplice = function(splice) { this.rowOffsetTree.fillFromValues(this.rowHeights); this.totalHeight(this.rowOffsetTree.getTotal() + this.options.paddingBottom); - // We may be seeing the last row with space below it, so we'll use the same logic as in - // scrollTo, to make sure the rendered range includes all rows we should be seeing. - var rowAtScrollTop = this.rowOffsetTree.getIndex(this.scrollTop); - this.begin = gutil.clamp(rowAtScrollTop - this.numBuffered, 0, this.numRows - this.numRendered); - this.end = gutil.clamp(this.begin + this.numRendered, 0, this.numRows); + this._updateRange(); this.scheduleUpdateSize(); }; @@ -617,6 +609,16 @@ Scrolly.prototype.destroyPane = function(pane) { } }; +/** + * Updates indexes of rows to render. + */ +Scrolly.prototype._updateRange = function() { + // If we are scrolled from the top, start at the first visible row with some buffer. + const begin = this.rowOffsetTree.getIndex(this.scrollTop) - this.numBuffered; + this.begin = gutil.clamp(begin, 0, this.numRows - this.numRendered); + this.end = gutil.clamp(this.begin + this.numRendered, 0, this.numRows); +} + //---------------------------------------------------------------------- /** diff --git a/test/fixtures/docs/Teams.grist b/test/fixtures/docs/Teams.grist new file mode 100644 index 0000000000000000000000000000000000000000..9dcfb53942c31f10a67e23b625ba84732bd8407e GIT binary patch literal 192512 zcmeI53w#vS_4sEtlk85C-P!P3-dQ$a5($AMgr`Un@*ol*BmseBvzhEp$iQYd>~4Sv z$ZmKDwmh_I)qiW%)=Jg3zG~I}RK&Jwv1(gwtuNZDt@T06ueSQb_V@drJF_#pvzZMm zU`y$l4{T=7J@?GH-*e~Aeay@@uV@fMg1yTh=;1^5GRjKPG*w}@Qxug3|EI%$Wi!AI zqkMtCH2gQkeb?Jfqly>)Ivr9B+}}w0WbRXWM^71LNB{{S0VIF~kN^@u0!RP}AOR$R z1dzZvCNO+77|b!7iCOD8wvFbH01`j~NB{{S0VIF~kN^@u0!RP}Ac6CWKqm19$N%S5 zOwbu5fCP{L50VIF~kN^@u0!RP}AOR$R z1dzb_M*zqF=U+_FBP4(XkN^@u0!RP}AOR$R1dsp{KmzBQ0FM99HBq#O1dsp{Kmter z2_OL^fCP{L58R;^}FZ+bes7favC@FB3Mq*7yS( zwmQ6iH}4f3^BjV2+RA1}5&T^z`iP*nKh*8_l{vPP@jt^oMsX*(x40K!2R9^u1dsp{ zKmter2_OL^fCP{L5B++W|SNkWJ(~Ojjd?V^X8yWv+XKkjqpK{B%apot@o6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