send file on enter

pull/16607/head
Guilherme Gazzo 6 years ago
parent d14dbd793d
commit 5bce20ee7e
No known key found for this signature in database
GPG Key ID: 2409387AEF14CB9D
  1. 25
      app/ui-utils/client/lib/modal.js

@ -160,26 +160,28 @@ export const modal = {
if (!modalStack.length) {
return;
}
const instance = modalStack[modalStack.length - 1];
if (instance && instance.config && instance.config.confirmOnEnter && event.key === 'Enter') {
if (event.key === 'Escape') {
event.preventDefault();
event.stopPropagation();
if (instance.config.input) {
return instance.confirm($('.js-modal-input').val());
}
instance.close();
}
instance.confirm(true);
if (!document.querySelector('.rc-modal__content').contains(event.target)) {
return;
}
if (event.key === 'Escape') {
if (instance && instance && instance.confirmOnEnter && event.key === 'Enter') {
event.preventDefault();
event.stopPropagation();
instance.close();
if (instance.input) {
return instance.confirm($('.js-modal-input').val());
}
instance.confirm(true);
}
},
};
@ -211,18 +213,20 @@ Template.rc_modal.helpers({
});
Template.rc_modal.onRendered(function() {
this.oldFocus = document.activeElement;
if (this.data.onRendered) {
this.data.onRendered();
}
if (this.data.input) {
$('.js-modal-input').focus();
$('.js-modal-input', this.firstNode).focus();
}
this.data.closeOnEscape && document.addEventListener('keydown', modal.onKeyDown);
});
Template.rc_modal.onDestroyed(function() {
this.oldFocus && this.oldFocus.focus();
document.removeEventListener('keydown', modal.onKeyDown);
});
@ -233,6 +237,7 @@ Template.rc_modal.events({
this.close();
},
'click .js-close'(e) {
e.preventDefault();
e.stopPropagation();
this.cancel();
},

Loading…
Cancel
Save