From 7d8cf2eb3d5eae1740163d78bcbdb771fbae5d11 Mon Sep 17 00:00:00 2001 From: Erick Guan Date: Thu, 21 May 2015 10:40:28 +0800 Subject: [PATCH] FIX: press ESC can close user card --- app/assets/javascripts/discourse/views/user-card.js.es6 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/javascripts/discourse/views/user-card.js.es6 b/app/assets/javascripts/discourse/views/user-card.js.es6 index 714f936fac5..2e01858f4b5 100644 --- a/app/assets/javascripts/discourse/views/user-card.js.es6 +++ b/app/assets/javascripts/discourse/views/user-card.js.es6 @@ -120,6 +120,14 @@ export default Discourse.View.extend(CleansUp, { this.get('controller').close(); }, + keyUp(e) { + if (e.keyCode === 27) { // ESC + const target = this.get('controller.cardTarget'); + this.cleanUp(); + target.focus(); + } + }, + _removeEvents: function() { $('html').off(clickOutsideEventName);