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:
Scott Nonnenberg 2017-06-14 10:37:30 -07:00
parent 243cbd8123
commit 2955c36b3e
3 changed files with 24 additions and 10 deletions

View file

@ -20,8 +20,9 @@
this.render();
},
events: {
'click .ok': 'ok',
'click .cancel': 'cancel',
'keyup': 'onKeyup',
'click .ok': 'ok',
'click .cancel': 'cancel',
},
render_attributes: function() {
return {
@ -31,12 +32,21 @@
};
},
ok: function() {
this.remove();
this.resolve();
this.remove();
this.resolve();
},
cancel: function() {
this.remove();
this.reject();
this.remove();
this.reject();
},
onKeyup: function(event) {
console.log('ConfirmationDialogView onKeyup', event);
if (event.key === 'Escape' || event.key === 'Esc') {
this.cancel();
}
},
focusCancel: function() {
this.$('.cancel').focus();
}
});
})();