From caac05dbba28dc33388e3b856efe5c7bf1f96889 Mon Sep 17 00:00:00 2001 From: cpradio Date: Mon, 22 Sep 2014 15:07:50 -0400 Subject: [PATCH] FIX: j/k place tab focus accordingly so tab will go to the first linked item in the selected post/row Allow tabbing to continue from the selected post/topic when using the j/k keyboard shortcuts https://meta.discourse.org/t/when-a-post-is-selected-tab-should-take-you-to-the-first-link/16212 --- .../javascripts/discourse/lib/keyboard_shortcuts.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js index abdf402e62e..8a8836bd54f 100644 --- a/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js +++ b/app/assets/javascripts/discourse/lib/keyboard_shortcuts.js @@ -233,6 +233,15 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({ if ($article.size() > 0) { $articles.removeClass('selected'); $article.addClass('selected'); + + if ($article.is('.topic-post')) { + var tabLoc = $article.find('a.tabLoc'); + if (tabLoc.length === 0) { + tabLoc = $(''); + $article.prepend(tabLoc); + } + tabLoc.focus(); + } var rgx = new RegExp("post-cloak-(\\d+)").exec($article.parent()[0].id); if (rgx === null || typeof rgx[1] === 'undefined') {