diff --git a/app/assets/javascripts/discourse/components/topic-list-item.js.es6 b/app/assets/javascripts/discourse/components/topic-list-item.js.es6 index f9b3cd38b76..f9ebaf7dd5f 100644 --- a/app/assets/javascripts/discourse/components/topic-list-item.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-list-item.js.es6 @@ -30,8 +30,9 @@ export default Ember.Component.extend(bufferedRender({ rerenderTriggers: ['bulkSelectEnabled', 'topic.pinned'], tagName: 'tr', classNameBindings: [':topic-list-item', 'unboundClassNames', 'topic.visited'], - attributeBindings: ['data-topic-id'], + attributeBindings: ['data-topic-id', 'tabindex'], 'data-topic-id': Em.computed.alias('topic.id'), + 'tabindex': 0, actions: { toggleBookmark() { diff --git a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 index e65240981e0..3274b9bfa58 100644 --- a/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 +++ b/app/assets/javascripts/discourse/lib/keyboard-shortcuts.js.es6 @@ -315,9 +315,15 @@ export default { return; } - const $selected = ($articles.filter('.selected').length !== 0) - ? $articles.filter('.selected') - : $articles.filter('[data-islastviewedtopic=true]'); + let $selected = $articles.filter(function(_, el) { + return el.contains(document.activeElement); // :focus + }); + if ($selected.length === 0) { + $selected = $articles.filter('.selected'); + } + if ($selected.length === 0) { + $selected = $articles.filter('[data-islastviewedtopic=true]'); + } let index = $articles.index($selected); if ($selected.length !== 0) { //boundries check @@ -354,10 +360,11 @@ export default { $article.addClass('selected'); if ($article.is('.topic-post')) { - $('a.tabLoc', $article).focus(); + $('article', $article).focus(); this._scrollToPost($article); } else { + $article.focus(); this._scrollList($article, direction); } } diff --git a/app/assets/javascripts/discourse/widgets/post.js.es6 b/app/assets/javascripts/discourse/widgets/post.js.es6 index 887493fd45e..a31bd578a7f 100644 --- a/app/assets/javascripts/discourse/widgets/post.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post.js.es6 @@ -394,11 +394,11 @@ createWidget('post-article', { }, buildAttributes(attrs) { - return { 'data-post-id': attrs.id, 'data-user-id': attrs.user_id }; + return { 'data-post-id': attrs.id, 'data-user-id': attrs.user_id, 'tabindex': '0' }; }, html(attrs, state) { - const rows = [h('a.tabLoc', { attributes: { href: ''} })]; + const rows = []; if (state.repliesAbove.length) { const replies = state.repliesAbove.map(p => { return this.attach('embedded-post', p, { model: this.store.createRecord('post', p), state: { above: true } });