Confirmation dialog: Make keyboard-accessible: escape to cancel
And proper tab order. Then some more work to re-focus on the message composition field after the dialog shows up and steals focus. FREEBIE
This commit is contained in:
parent
243cbd8123
commit
2955c36b3e
3 changed files with 24 additions and 10 deletions
|
@ -166,8 +166,8 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class='message'>{{ message }}</div>
|
<div class='message'>{{ message }}</div>
|
||||||
<div class='buttons'>
|
<div class='buttons'>
|
||||||
<button class='cancel'>{{ cancel }}</button>
|
<button class='cancel' tabindex='2'>{{ cancel }}</button>
|
||||||
<button class='ok'>{{ ok }}</button>
|
<button class='ok' tabindex='1'>{{ ok }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -20,8 +20,9 @@
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
'click .ok': 'ok',
|
'keyup': 'onKeyup',
|
||||||
'click .cancel': 'cancel',
|
'click .ok': 'ok',
|
||||||
|
'click .cancel': 'cancel',
|
||||||
},
|
},
|
||||||
render_attributes: function() {
|
render_attributes: function() {
|
||||||
return {
|
return {
|
||||||
|
@ -31,12 +32,21 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
ok: function() {
|
ok: function() {
|
||||||
this.remove();
|
this.remove();
|
||||||
this.resolve();
|
this.resolve();
|
||||||
},
|
},
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
this.remove();
|
this.remove();
|
||||||
this.reject();
|
this.reject();
|
||||||
|
},
|
||||||
|
onKeyup: function(event) {
|
||||||
|
console.log('ConfirmationDialogView onKeyup', event);
|
||||||
|
if (event.key === 'Escape' || event.key === 'Esc') {
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focusCancel: function() {
|
||||||
|
this.$('.cancel').focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -689,10 +689,12 @@
|
||||||
this.checkUnverifiedSendMessage(e, {force: true});
|
this.checkUnverifiedSendMessage(e, {force: true});
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
reject: function() {
|
reject: function() {
|
||||||
// do nothing
|
this.focusMessageField();
|
||||||
}
|
}.bind(this)
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$el.prepend(dialog.el);
|
this.$el.prepend(dialog.el);
|
||||||
|
dialog.focusCancel();
|
||||||
},
|
},
|
||||||
|
|
||||||
checkUnverifiedSendMessage: function(e, options) {
|
checkUnverifiedSendMessage: function(e, options) {
|
||||||
|
@ -750,6 +752,8 @@
|
||||||
var message = this.replace_colons(input.val()).trim();
|
var message = this.replace_colons(input.val()).trim();
|
||||||
var convo = this.model;
|
var convo = this.model;
|
||||||
|
|
||||||
|
this.focusMessageField();
|
||||||
|
|
||||||
if (message.length > 0 || this.fileInput.hasFiles()) {
|
if (message.length > 0 || this.fileInput.hasFiles()) {
|
||||||
this.fileInput.getFiles().then(function(attachments) {
|
this.fileInput.getFiles().then(function(attachments) {
|
||||||
convo.sendMessage(message, attachments);
|
convo.sendMessage(message, attachments);
|
||||||
|
|
Loading…
Reference in a new issue