This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree 3 files changed +28
-0
lines changed
3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,11 @@ dialogModule.provider("$dialog", function(){
93
93
e . preventDefault ( ) ;
94
94
self . $scope . $apply ( ) ;
95
95
} ;
96
+
97
+ this . handleLocationChange = function ( ) {
98
+ self . close ( ) ;
99
+ self . $scope . $apply ( ) ;
100
+ } ;
96
101
}
97
102
98
103
// The `isOpen()` method returns wether the dialog is currently visible.
@@ -184,6 +189,8 @@ dialogModule.provider("$dialog", function(){
184
189
Dialog . prototype . _bindEvents = function ( ) {
185
190
if ( this . options . keyboard ) { body . bind ( 'keydown' , this . handledEscapeKey ) ; }
186
191
if ( this . options . backdrop && this . options . backdropClick ) { this . backdropEl . bind ( 'click' , this . handleBackDropClick ) ; }
192
+
193
+ this . $scope . $on ( '$locationChangeSuccess' , this . handleLocationChange ) ;
187
194
} ;
188
195
189
196
Dialog . prototype . _unbindEvents = function ( ) {
Original file line number Diff line number Diff line change @@ -59,6 +59,11 @@ describe('Given ui.bootstrap.dialog', function(){
59
59
var clearGlobalOptions = function ( ) {
60
60
provider . options ( { } ) ;
61
61
} ;
62
+
63
+ var changeLocation = function ( ) {
64
+ $rootScope . $broadcast ( '$locationChangeSuccess' ) ;
65
+ $rootScope . $apply ( ) ;
66
+ } ;
62
67
63
68
var dialogShouldBeClosed = function ( ) {
64
69
it ( 'should not include a backdrop in the DOM' , function ( ) {
@@ -287,6 +292,16 @@ describe('Given ui.bootstrap.dialog', function(){
287
292
expect ( $document . find ( 'body > div.modal > div.modal-header' ) . length ) . toBe ( 1 ) ;
288
293
} ) ;
289
294
} ) ;
295
+
296
+ describe ( 'When dialog is open and location changes' , function ( ) {
297
+ beforeEach ( function ( ) {
298
+ createDialog ( { template :template } ) ;
299
+ openDialog ( ) ;
300
+ changeLocation ( ) ;
301
+ } ) ;
302
+
303
+ dialogShouldBeClosed ( ) ;
304
+ } ) ;
290
305
291
306
describe ( 'when opening it with a template containing white-space' , function ( ) {
292
307
Original file line number Diff line number Diff line change @@ -169,5 +169,11 @@ describe('Give ui.boostrap.modal', function() {
169
169
$scope . $digest ( ) ;
170
170
expect ( $scope . modalShown ) . not . toBeTruthy ( ) ;
171
171
} ) ;
172
+
173
+ it ( 'should update the model if the location change is successful' , function ( ) {
174
+ $rootScope . $broadcast ( '$locationChangeSuccess' ) ;
175
+ $scope . $digest ( ) ;
176
+ expect ( $scope . modalShown ) . not . toBeTruthy ( ) ;
177
+ } ) ;
172
178
} ) ;
173
179
} ) ;
You can’t perform that action at this time.
0 commit comments