Skip to content

Commit

Permalink
ENGCOM-7195: Fixed the wrong behavior for a prompt modal when a user …
Browse files Browse the repository at this point in the history
…clicks on the modal overlay #27399
  • Loading branch information
slavvka authored Apr 1, 2020
2 parents 89bc078 + 4fb6a23 commit 596607b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/code/Magento/Ui/view/base/web/js/modal/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ define([
_create: function () {
this.options.focus = this.options.promptField;
this.options.validation = this.options.validation && this.options.validationRules.length;
this.options.outerClickHandler = this.options.outerClickHandler || _.bind(this.closeModal, this, false);
this._super();
this.modal.find(this.options.modalContent).append(this.getFormTemplate());
this.modal.find(this.options.modalCloseBtn).off().on('click', _.bind(this.closeModal, this, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,20 @@ define([
'use strict';

describe('ui/js/modal/prompt', function () {
var element = $('<div>some element</div>'),

var element,
prompt,
widget;

beforeEach(function () {
element = $('<div id="element">some element</div>'),
prompt = element.prompt({});
widget = element.prompt({}).data('mage-prompt');
});

afterEach(function () {
$('#element').remove();
});

it('Check for modal definition', function () {
expect(prompt).toBeDefined();
Expand All @@ -23,5 +35,12 @@ define([
it('Integration: modal created on page', function () {
expect(prompt.length).toEqual(1);
});
it('Check cancel action', function () {
var cancel = spyOn(widget.options.actions, 'cancel');

jQuery('.modals-overlay').click();
expect(widget.options.outerClickHandler).toBeDefined();
expect(cancel).toHaveBeenCalled();
});
});
});

0 comments on commit 596607b

Please sign in to comment.