diff --git a/app/assets/javascripts/discourse/views/flag.js.es6 b/app/assets/javascripts/discourse/views/flag.js.es6 index b948c35f0aa..583452fca48 100644 --- a/app/assets/javascripts/discourse/views/flag.js.es6 +++ b/app/assets/javascripts/discourse/views/flag.js.es6 @@ -8,15 +8,13 @@ export default ModalBodyView.extend({ }.property('controller.flagTopic'), selectedChanged: function() { - const self = this; + Em.run.next(() => { + this.$("input[type='radio']").prop('checked', false); - Em.run.next(function() { - self.$("input[type='radio']").prop('checked', false); - - const nameKey = self.get('controller.selected.name_key'); + const nameKey = this.get('controller.selected.name_key'); if (!nameKey) { return; } - self.$('#radio_' + nameKey).prop('checked', 'true'); + this.$('#radio_' + nameKey).prop('checked', 'true'); }); }.observes('controller.selected.name_key') }); diff --git a/app/assets/javascripts/discourse/views/modal.js.es6 b/app/assets/javascripts/discourse/views/modal.js.es6 index 4621445dc6b..f1af3bb33d3 100644 --- a/app/assets/javascripts/discourse/views/modal.js.es6 +++ b/app/assets/javascripts/discourse/views/modal.js.es6 @@ -3,7 +3,7 @@ export default Ember.View.extend({ templateName: 'modal/modal', classNameBindings: [':modal', ':hidden', 'controller.modalClass'], - click: function(e) { + click(e) { const $target = $(e.target); if ($target.hasClass("modal-middle-container") || $target.hasClass("modal-outer-container")) { @@ -12,5 +12,12 @@ export default Ember.View.extend({ // the backdrop and makes it unclickable. $('.modal-header a.close').click(); } + }, + + keyDown(e) { + // Delegate click to modal close when pressing ESC + if (e.keyCode === 27) { + Em.run.next(() => $('.modal-header a.close').click()); + } } });