From b19d5cb2f4eef0b992b4b5964b29c18d2bf8c40b Mon Sep 17 00:00:00 2001 From: Karl Seamon Date: Tue, 24 Nov 2015 17:45:35 -0500 Subject: [PATCH] fix(virtualRepeat, autoComplete): Recompute number of items after auto-(un)shrink. --- src/components/virtualRepeat/virtual-repeater.js | 2 ++ src/components/virtualRepeat/virtual-repeater.spec.js | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/components/virtualRepeat/virtual-repeater.js b/src/components/virtualRepeat/virtual-repeater.js index 33c2fd0a37b..11c83c53a77 100644 --- a/src/components/virtualRepeat/virtual-repeater.js +++ b/src/components/virtualRepeat/virtual-repeater.js @@ -253,6 +253,8 @@ VirtualRepeatContainerController.prototype.autoShrink_ = function(size) { this.setSize_(this.originalSize); this.originalSize = null; } + + this.repeater.containerUpdated(); } }; diff --git a/src/components/virtualRepeat/virtual-repeater.spec.js b/src/components/virtualRepeat/virtual-repeater.spec.js index c2c48acbbcc..b483f578397 100644 --- a/src/components/virtualRepeat/virtual-repeater.spec.js +++ b/src/components/virtualRepeat/virtual-repeater.spec.js @@ -303,21 +303,25 @@ describe('', 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() { @@ -331,21 +335,25 @@ describe('', 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() {