From 1fdf9038dbac368c6d63aba49f04ee5dfd1a8ec7 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 10 Mar 2015 16:33:14 +1100 Subject: [PATCH] FIX: clicking on username was causing page to scroll all the way up --- app/assets/javascripts/discourse/views/user-card.js.es6 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/views/user-card.js.es6 b/app/assets/javascripts/discourse/views/user-card.js.es6 index 16012a2f786..62721328136 100644 --- a/app/assets/javascripts/discourse/views/user-card.js.es6 +++ b/app/assets/javascripts/discourse/views/user-card.js.es6 @@ -76,7 +76,11 @@ export default Discourse.View.extend(CleansUp, { _shown() { // After the card is shown, focus on the first link - Ember.run.scheduleOnce('afterRender', () => this.$('a:first').focus() ); + // + // note: we DO NOT use afterRender here cause _willShow may + // run after _shown, if we allowed this to happen the usercard + // may be offscreen and we may scroll all the way to it on focus + Ember.run.next(null, () => this.$('a:first').focus() ); }, _willShow(target) {