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

Commit

Permalink
fix(virtualRepeat, autoComplete): Recompute number of items after aut…
Browse files Browse the repository at this point in the history
…o-(un)shrink.
  • Loading branch information
kseamon authored and jelbourn committed Nov 25, 2015
1 parent 19c2df8 commit b19d5cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/virtualRepeat/virtual-repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ VirtualRepeatContainerController.prototype.autoShrink_ = function(size) {
this.setSize_(this.originalSize);
this.originalSize = null;
}

this.repeater.containerUpdated();
}
};

Expand Down
8 changes: 8 additions & 0 deletions src/components/virtualRepeat/virtual-repeater.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,21 +303,25 @@ describe('<md-virtual-repeat>', function() {
$$rAF.flush();

expect(container[0].offsetHeight).toBe(100);
expect(offsetter.children().length).toBe(13);

// With 5 items...
scope.items = createItems(5);
scope.$apply();
expect(container[0].offsetHeight).toBe(5 * ITEM_SIZE);
expect(offsetter.children().length).toBe(5);

// With 0 items...
scope.items = [];
scope.$apply();
expect(container[0].offsetHeight).toBe(0);
expect(offsetter.children().length).toBe(0);

// With lots of items again...
scope.items = createItems(NUM_ITEMS);
scope.$apply();
expect(container[0].offsetHeight).toBe(100);
expect(offsetter.children().length).toBe(13);
});

it('should shrink the container when the number of items goes down (horizontal)', function() {
Expand All @@ -331,21 +335,25 @@ describe('<md-virtual-repeat>', function() {
$$rAF.flush();

expect(container[0].offsetWidth).toBe(150);
expect(offsetter.children().length).toBe(18);

// With 5 items...
scope.items = createItems(5);
scope.$apply();
expect(container[0].offsetWidth).toBe(5 * ITEM_SIZE);
expect(offsetter.children().length).toBe(5);

// With 0 items...
scope.items = [];
scope.$apply();
expect(container[0].offsetWidth).toBe(0);
expect(offsetter.children().length).toBe(0);

// With lots of items again...
scope.items = createItems(NUM_ITEMS);
scope.$apply();
expect(container[0].offsetWidth).toBe(150);
expect(offsetter.children().length).toBe(18);
});

it('should not shrink below the specified md-auto-shrink-min (vertical)', function() {
Expand Down

0 comments on commit b19d5cb

Please sign in to comment.