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
…25349

 - Merge Pull Request #25349 from konarshankar07/magento2:escapekey-issue-onprompt-close
 - Merged commits:
   1. a4a2ff7
   2. c42d48a
   3. b8e0c42
   4. d6995f7
   5. c9f9757
   6. 240fc19
   7. da6b361
   8. db51191
   9. 3e25bd1
   10. 633ea17
   11. 5d676b6
   12. 997959f
   13. d3aa932
   14. 65b2afe
   15. 727679d
   16. b41ea13
   17. 552eaaf
   18. ce6614e
   19. c14fbed
   20. 257eb00
   21. b1ab6a9
   22. 53fe8ee
   23. 437fab3
  • Loading branch information
magento-engcom-team committed Feb 24, 2020
2 parents 9003079 + 437fab3 commit f29aebb
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 f29aebb

Please sign in to comment.