Skip to content

Commit

Permalink
ENGCOM-6284: Fixed issue when escape key is pressed to close prompt #…
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka authored Feb 24, 2020
2 parents ca6ec09 + f29aebb commit 6d04ead
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/view/base/web/js/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ define([
* Close modal.
* * @return {Element} - current element.
*/
closeModal: function () {
closeModal: function (event, result) {//eslint-disable-line no-unused-vars
var that = this;

this._removeKeyListener();
Expand Down
21 changes: 12 additions & 9 deletions app/code/Magento/Ui/view/base/web/js/modal/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ define([
/**
* Click handler.
*/
click: function () {
this.closeModal();
click: function (event) {
this.closeModal(event);
}
}, {
text: $.mage.__('OK'),
Expand All @@ -61,8 +61,8 @@ define([
/**
* Click handler.
*/
click: function () {
this.closeModal(true);
click: function (event) {
this.closeModal(event, true);
}
}]
},
Expand All @@ -75,7 +75,7 @@ define([
this.options.validation = this.options.validation && this.options.validationRules.length;
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));
this.modal.find(this.options.modalCloseBtn).off().on('click', _.bind(this.closeModal, this));

if (this.options.validation) {
this.setValidationClasses();
Expand Down Expand Up @@ -152,21 +152,23 @@ define([
/**
* Close modal window
*/
closeModal: function (result) {
closeModal: function (event, result) {
var value;

result = result || false;

if (result) {
if (this.options.validation && !this.validate()) {
return false;
}

value = this.modal.find(this.options.promptField).val();
this.options.actions.confirm.call(this, value);
this.options.actions.confirm.call(event, value);
} else {
this.options.actions.cancel.call(this, result);
this.options.actions.cancel.call(event, result);
}

this.options.actions.always();
this.options.actions.always(event);
this.element.bind('promptclosed', _.bind(this._remove, this));

return this._super();
Expand All @@ -177,3 +179,4 @@ define([
return $('<div class="prompt-message"></div>').html(config.content).prompt(config);
};
});

0 comments on commit 6d04ead

Please sign in to comment.