Skip to content

Commit d11559e

Browse files
committed
Avoid issue with tracked prop being read and then changed in the same render
1 parent 961e47a commit d11559e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

addon/components/scroll-view.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Hammer from 'hammerjs';
1010
import ZyngaScrollerVerticalRecognizer from 'yapp-scroll-view/utils/zynga-scroller-vertical-recognizer';
1111
import { join, schedule } from '@ember/runloop';
1212
import { translate } from 'ember-collection/utils/translate';
13-
import { timeout } from 'ember-concurrency';
13+
import { timeout, waitForQueue } from 'ember-concurrency';
1414
import { task } from 'ember-concurrency-decorators';
1515
import ScrollViewApi from 'yapp-scroll-view/utils/scroll-view-api';
1616
import { DEBUG } from '@glimmer/env';
@@ -106,8 +106,10 @@ class ScrollView extends Component {
106106
_isAtTop;
107107
_needsContentSizeUpdate = true;
108108
_appliedClientWidth;
109-
@tracked _appliedClientHeight;
110-
@tracked _appliedContentHeight;
109+
_appliedClientHeight;
110+
_appliedContentHeight;
111+
@tracked scrollBarClientHeight;
112+
@tracked scrollBarContentHeight;
111113
_appliedScrollTop;
112114
_shouldMeasureContent = undefined;
113115
_isScrolling = false;
@@ -473,12 +475,20 @@ class ScrollView extends Component {
473475
this._appliedClientHeight = clientHeight;
474476
this._appliedContentHeight = contentHeight;
475477
this.contentElement.style.minHeight = `${clientHeight}px`;
478+
this.updateScrollBarDimensionsTask.perform();
476479
this.updateScrollerDimensions();
477480
if (this.args.clientSizeChange) {
478481
this.args.clientSizeChange(clientWidth, clientHeight);
479482
}
480483
}
481484

485+
@task
486+
*updateScrollBarDimensionsTask() {
487+
yield waitForQueue('afterRender');
488+
this.scrollBarClientHeight = this._appliedClientHeight;
489+
this.scrollBarContentHeight = this._appliedContentHeight;
490+
}
491+
482492
get extraCssClasses() {
483493
// for overriding by LoadingScrollView
484494
return null;

addon/templates/components/scroll-view.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<VerticalScrollBar
1515
data-test-scroll-bar
1616
class="ScrollView-scrollBar"
17-
@contentHeight={{this._appliedContentHeight}}
18-
@scrollerHeight={{this._appliedClientHeight}}
17+
@contentHeight={{this.scrollBarContentHeight}}
18+
@scrollerHeight={{this.scrollBarClientHeight}}
1919
@registerWithScrollView={{action this.scrollViewApi.registerScrollPositionCallback}}
2020
/>
2121
{{emitter-action

0 commit comments

Comments
 (0)