Skip to content

Commit 4fb6a23

Browse files
ENGCOM-7195: Fixed the wrong behavior for a prompt modal when a user clicks on the modal overlay #27399
- Merge Pull Request #27399 from serhiyzhovnir/magento2:fix-adobe-stock-issue-1002 - Merged commits: 1. 9c5528f 2. e428056 3. 9735426 4. c83fbc6 5. 8e4a197
2 parents 89bc078 + 8e4a197 commit 4fb6a23

File tree

2 files changed

+21
-1
lines changed
  • app/code/Magento/Ui/view/base/web/js/modal
  • dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal

2 files changed

+21
-1
lines changed

app/code/Magento/Ui/view/base/web/js/modal/prompt.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ define([
111111
_create: function () {
112112
this.options.focus = this.options.promptField;
113113
this.options.validation = this.options.validation && this.options.validationRules.length;
114+
this.options.outerClickHandler = this.options.outerClickHandler || _.bind(this.closeModal, this, false);
114115
this._super();
115116
this.modal.find(this.options.modalContent).append(this.getFormTemplate());
116117
this.modal.find(this.options.modalCloseBtn).off().on('click', _.bind(this.closeModal, this, false));

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/prompt.test.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,20 @@ define([
1010
'use strict';
1111

1212
describe('ui/js/modal/prompt', function () {
13-
var element = $('<div>some element</div>'),
13+
14+
var element,
15+
prompt,
16+
widget;
17+
18+
beforeEach(function () {
19+
element = $('<div id="element">some element</div>'),
1420
prompt = element.prompt({});
21+
widget = element.prompt({}).data('mage-prompt');
22+
});
23+
24+
afterEach(function () {
25+
$('#element').remove();
26+
});
1527

1628
it('Check for modal definition', function () {
1729
expect(prompt).toBeDefined();
@@ -23,5 +35,12 @@ define([
2335
it('Integration: modal created on page', function () {
2436
expect(prompt.length).toEqual(1);
2537
});
38+
it('Check cancel action', function () {
39+
var cancel = spyOn(widget.options.actions, 'cancel');
40+
41+
jQuery('.modals-overlay').click();
42+
expect(widget.options.outerClickHandler).toBeDefined();
43+
expect(cancel).toHaveBeenCalled();
44+
});
2645
});
2746
});

0 commit comments

Comments
 (0)