Skip to content

Commit 1fbd3c5

Browse files
committed
fix(collectionRepeat): properly display collection repeat inside a modal
1 parent 4e6ba5b commit 1fbd3c5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Diff for: js/angular/directive/collectionRepeat.js

+5
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ function($collectionRepeatManager, $collectionDataSource, $parse) {
225225
rerender($scope.$eval(listExpr));
226226
}
227227

228+
// for lists inside a modal, recalc when the modal is shown
229+
$scope.$on('modal.shown',function(){
230+
onWindowResize();
231+
});
232+
228233
ionic.on('resize', onWindowResize, window);
229234

230235
$scope.$on('$destroy', function() {

Diff for: test/unit/angular/directive/collectionRepeat.unit.js

+18
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,24 @@ describe('collectionRepeat directive', function() {
152152
expect(scrollView.resize.callCount).toBe(1);
153153
});
154154

155+
it('should rerender on modal popup', function() {
156+
inject(function($rootScope) {
157+
var el = setup('collection-repeat="item in items" collection-item-height="50"');
158+
var scrollView = el.controller('$ionicScroll').scrollView;
159+
spyOn(scrollView, 'resize');
160+
dataSource.setData.reset();
161+
repeatManager.resize.reset();
162+
163+
el.scope().items = [1, 2, 3];
164+
165+
$rootScope.$broadcast('modal.shown');
166+
167+
expect(dataSource.setData).toHaveBeenCalledWith(el.scope().items);
168+
expect(repeatManager.resize.callCount).toBe(1);
169+
expect(scrollView.resize.callCount).toBe(1);
170+
});
171+
});
172+
155173
it('$destroy', function() {
156174
var el = setup('collection-repeat="item in items" collection-item-height="50"');
157175
dataSource.destroy = jasmine.createSpy('dataSourceDestroy');

0 commit comments

Comments
 (0)