@@ -153,11 +153,7 @@ define([
153
153
class : buttons . cancel . class ? buttons . cancel . class : 'action secondary action-hide-popup' ,
154
154
155
155
/** @inheritdoc */
156
- click : function ( ) {
157
- // Revert address.
158
- checkoutData . setShippingAddressFromData ( self . tempData ) ;
159
- this . closeModal ( ) ;
160
- }
156
+ click : this . onClosePopUp . bind ( this )
161
157
}
162
158
] ;
163
159
@@ -166,6 +162,11 @@ define([
166
162
self . isFormPopUpVisible ( false ) ;
167
163
} ;
168
164
165
+ this . popUpForm . options . modalCloseBtnHandler = this . onClosePopUp . bind ( this ) ;
166
+ this . popUpForm . options . keyEventHandlers = {
167
+ escapeKey : this . onClosePopUp . bind ( this )
168
+ } ;
169
+
169
170
/** @inheritdoc */
170
171
this . popUpForm . options . opened = function ( ) {
171
172
// Store temporary address for revert action in case when user click cancel action
@@ -177,6 +178,14 @@ define([
177
178
return popUp ;
178
179
} ,
179
180
181
+ /**
182
+ * Revert address and close modal.
183
+ */
184
+ onClosePopUp : function ( ) {
185
+ checkoutData . setShippingAddressFromData ( $ . extend ( true , { } , this . temporaryAddress ) ) ;
186
+ this . getPopUp ( ) . closeModal ( ) ;
187
+ } ,
188
+
180
189
/**
181
190
* Show address form popup
182
191
*/
@@ -203,7 +212,7 @@ define([
203
212
newShippingAddress = createShippingAddress ( addressData ) ;
204
213
selectShippingAddress ( newShippingAddress ) ;
205
214
checkoutData . setSelectedShippingAddress ( newShippingAddress . getKey ( ) ) ;
206
- checkoutData . setNewCustomerShippingAddress ( addressData ) ;
215
+ checkoutData . setNewCustomerShippingAddress ( $ . extend ( true , { } , addressData ) ) ;
207
216
this . getPopUp ( ) . closeModal ( ) ;
208
217
this . isNewAddressAdded ( true ) ;
209
218
}
0 commit comments