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
This commit is contained in:
cpradio 2014-09-22 15:07:50 -04:00
parent d97548114f
commit caac05dbba
1 changed files with 9 additions and 0 deletions

View File

@ -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 = $('<a href="#" class="tabLoc"></a>');
$article.prepend(tabLoc);
}
tabLoc.focus();
}
var rgx = new RegExp("post-cloak-(\\d+)").exec($article.parent()[0].id);
if (rgx === null || typeof rgx[1] === 'undefined') {