Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 25aeb0d

Browse files
ppham27mmalerba
authored andcommitted
fix(virtualRepeat): DOM manipulation may alter scroll (#10177)
Fixes [#10144](#10144) - There is an issue with Chrome that when the browser window is small enough, the intial DOM manipulations alter the scroll, which leads to the caldendar opening to the wrong month. Scrolling twice on the first render to ensure that the position is correct fixes this.
1 parent 1095899 commit 25aeb0d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/virtualRepeat/virtual-repeater.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,12 +761,14 @@ VirtualRepeatController.prototype.virtualRepeatUpdate_ = function(items, oldItem
761761
this.container.setScrollSize(itemsLength * this.itemSize);
762762
}
763763

764+
var cleanupFirstRender = false, firstRenderStartIndex;
764765
if (this.isFirstRender) {
766+
cleanupFirstRender = true;
765767
this.isFirstRender = false;
766-
var startIndex = this.$attrs.mdStartIndex ?
768+
firstRenderStartIndex = this.$attrs.mdStartIndex ?
767769
this.$scope.$eval(this.$attrs.mdStartIndex) :
768770
this.container.topIndex;
769-
this.container.scrollToIndex(startIndex);
771+
this.container.scrollToIndex(firstRenderStartIndex);
770772
}
771773

772774
// Detach and pool any blocks that are no longer in the viewport.
@@ -820,6 +822,10 @@ VirtualRepeatController.prototype.virtualRepeatUpdate_ = function(items, oldItem
820822
this.blocks[maxIndex] && this.blocks[maxIndex].element[0].nextSibling);
821823
}
822824

825+
// DOM manipulation may have altered scroll, so scroll again
826+
if (cleanupFirstRender) {
827+
this.container.scrollToIndex(firstRenderStartIndex);
828+
}
823829
// Restore $$checkUrlChange.
824830
this.$browser.$$checkUrlChange = this.browserCheckUrlChange;
825831

0 commit comments

Comments
 (0)