Skip to content

Commit b7f45e7

Browse files
committed
fix(view): don't affect history when inside a modal
Closes #1667
1 parent 5da1ecd commit b7f45e7

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ IonicModule
88
restrict: 'E',
99
transclude: true,
1010
replace: true,
11+
controller: [function(){}],
1112
template: '<div class="modal-backdrop">' +
1213
'<div class="modal-wrapper" ng-transclude></div>' +
1314
'</div>'

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ IonicModule
3535
return {
3636
restrict: 'EA',
3737
priority: 1000,
38-
require: '^?ionNavBar',
38+
require: ['^?ionNavBar', '^?ionModal'],
3939
compile: function(tElement, tAttrs, transclude) {
4040
tElement.addClass('pane');
4141
tElement[0].removeAttribute('title');
4242

43-
return function link($scope, $element, $attr, navBarCtrl) {
44-
if (!navBarCtrl) {
43+
return function link($scope, $element, $attr, ctrls) {
44+
var navBarCtrl = ctrls[0];
45+
var modalCtrl = ctrls[1];
46+
47+
//Don't use the ionView if we're inside a modal or there's no navbar
48+
if (!navBarCtrl || modalCtrl) {
4549
return;
4650
}
4751

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ describe('ionView directive', function() {
2121
return el;
2222
}
2323

24-
it('should remove title & add pane, even with no navbar', inject(function($compile, $rootScope) {
24+
it('should only remove title & add pane with no navbar', inject(function($compile, $rootScope) {
2525
var el = $compile('<ion-view title="1">')($rootScope.$new());
2626
$rootScope.$apply();
2727
expect(el.hasClass('pane')).toBe(true);
2828
expect(el[0].getAttribute('title')).toBe(null);
2929
}));
3030

31+
it('should only remove title & add pane in a modal',inject(function($compile, $rootScope) {
32+
var el = $compile('<ion-modal><ion-view title="1"></ion-modal>')($rootScope.$new());
33+
var view = jqLite(el[0].querySelector('.pane'));
34+
$rootScope.$apply();
35+
expect(view.hasClass('pane')).toBe(true);
36+
expect(view[0].getAttribute('title')).toBe(null);
37+
}));
38+
3139
it('should have content inside', function() {
3240
var el = setup(null, null, '<b>some</b> html');
3341
expect(el.html()).toBe('<b>some</b> html');

0 commit comments

Comments
 (0)