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

Commit

Permalink
fix(virtual-repeat): auto shrink restored wrong original size.
Browse files Browse the repository at this point in the history
* This broke the autocompletes height determination, when the matches array is empty.

Fixes #7955.

Closes #8095
  • Loading branch information
devversion authored and ThomasBurleson committed Apr 19, 2016
1 parent b99e74d commit 7e5be01
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/components/virtualRepeat/virtual-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ VirtualRepeatContainerController.prototype.getSize = function() {
/**
* Resizes the container.
* @private
* @param {number} The new size to set.
* @param {number} size The new size to set.
*/
VirtualRepeatContainerController.prototype.setSize_ = function(size) {
var dimension = this.getDimensionName_();
Expand All @@ -201,6 +201,7 @@ VirtualRepeatContainerController.prototype.unsetSize_ = function() {

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

this.size = this.isHorizontal()
Expand Down Expand Up @@ -274,22 +275,35 @@ VirtualRepeatContainerController.prototype.sizeScroller_ = function(size) {
*/
VirtualRepeatContainerController.prototype.autoShrink_ = function(size) {
var shrinkSize = Math.max(size, this.autoShrinkMin * this.repeater.getItemSize());

if (this.autoShrink && shrinkSize !== this.size) {
if (this.oldElementSize === null) {
this.oldElementSize = this.$element[0].style[this.getDimensionName_()];
}

var currentSize = this.originalSize || this.size;

if (!currentSize || shrinkSize < currentSize) {
if (!this.originalSize) {
this.originalSize = this.size;
}

// Now we update the containers size, because shrinking is enabled.
this.setSize_(shrinkSize);
} else if (this.originalSize !== null) {
// Set the size back to our initial size.
this.unsetSize_();

var _originalSize = this.originalSize;
this.originalSize = null;
this.updateSize();

// We determine the repeaters size again, if the original size was zero.
// The originalSize needs to be null, to be able to determine the size.
if (!_originalSize) this.updateSize();

// Apply the original size or the determined size back to the container, because
// it has been overwritten before, in the shrink block.
this.setSize_(_originalSize || this.size);
}

this.repeater.containerUpdated();
Expand Down

0 comments on commit 7e5be01

Please sign in to comment.