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

Commit 7e5be01

Browse files
devversionThomasBurleson
authored andcommitted
fix(virtual-repeat): auto shrink restored wrong original size.
* This broke the autocompletes height determination, when the matches array is empty. Fixes #7955. Closes #8095
1 parent b99e74d commit 7e5be01

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/components/virtualRepeat/virtual-repeater.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ VirtualRepeatContainerController.prototype.getSize = function() {
183183
/**
184184
* Resizes the container.
185185
* @private
186-
* @param {number} The new size to set.
186+
* @param {number} size The new size to set.
187187
*/
188188
VirtualRepeatContainerController.prototype.setSize_ = function(size) {
189189
var dimension = this.getDimensionName_();
@@ -201,6 +201,7 @@ VirtualRepeatContainerController.prototype.unsetSize_ = function() {
201201

202202
/** Instructs the container to re-measure its size. */
203203
VirtualRepeatContainerController.prototype.updateSize = function() {
204+
// If the original size is already determined, we can skip the update.
204205
if (this.originalSize) return;
205206

206207
this.size = this.isHorizontal()
@@ -274,22 +275,35 @@ VirtualRepeatContainerController.prototype.sizeScroller_ = function(size) {
274275
*/
275276
VirtualRepeatContainerController.prototype.autoShrink_ = function(size) {
276277
var shrinkSize = Math.max(size, this.autoShrinkMin * this.repeater.getItemSize());
278+
277279
if (this.autoShrink && shrinkSize !== this.size) {
278280
if (this.oldElementSize === null) {
279281
this.oldElementSize = this.$element[0].style[this.getDimensionName_()];
280282
}
281283

282284
var currentSize = this.originalSize || this.size;
285+
283286
if (!currentSize || shrinkSize < currentSize) {
284287
if (!this.originalSize) {
285288
this.originalSize = this.size;
286289
}
287290

291+
// Now we update the containers size, because shrinking is enabled.
288292
this.setSize_(shrinkSize);
289293
} else if (this.originalSize !== null) {
294+
// Set the size back to our initial size.
290295
this.unsetSize_();
296+
297+
var _originalSize = this.originalSize;
291298
this.originalSize = null;
292-
this.updateSize();
299+
300+
// We determine the repeaters size again, if the original size was zero.
301+
// The originalSize needs to be null, to be able to determine the size.
302+
if (!_originalSize) this.updateSize();
303+
304+
// Apply the original size or the determined size back to the container, because
305+
// it has been overwritten before, in the shrink block.
306+
this.setSize_(_originalSize || this.size);
293307
}
294308

295309
this.repeater.containerUpdated();

0 commit comments

Comments
 (0)