Merge pull request #2798 from lidlanca/patch-3
Fix: rapid/continuous keyboard Next event under Topics List view may lose selected item on "load more"
This commit is contained in:
commit
0855fe5438
|
@ -202,8 +202,11 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
|
||||||
var $selected = $articles.filter('.selected'),
|
var $selected = $articles.filter('.selected'),
|
||||||
index = $articles.index($selected);
|
index = $articles.index($selected);
|
||||||
|
|
||||||
// loop is not allowed
|
if($selected.length !== 0){ //boundries check
|
||||||
if (direction === -1 && index === 0) { return; }
|
// loop is not allowed
|
||||||
|
if (direction === -1 && index === 0) { return; }
|
||||||
|
if (direction === 1 && index === ($articles.size()-1) ) { return;}
|
||||||
|
}
|
||||||
|
|
||||||
// if nothing is selected go to the first post on screen
|
// if nothing is selected go to the first post on screen
|
||||||
if ($selected.length === 0) {
|
if ($selected.length === 0) {
|
||||||
|
@ -229,9 +232,7 @@ Discourse.KeyboardShortcuts = Ember.Object.createWithMixins({
|
||||||
|
|
||||||
if ($article.size() > 0) {
|
if ($article.size() > 0) {
|
||||||
$articles.removeClass('selected');
|
$articles.removeClass('selected');
|
||||||
Em.run.next(function(){
|
$article.addClass('selected');
|
||||||
$article.addClass('selected');
|
|
||||||
});
|
|
||||||
|
|
||||||
var rgx = new RegExp("post-cloak-(\\d+)").exec($article.parent()[0].id);
|
var rgx = new RegExp("post-cloak-(\\d+)").exec($article.parent()[0].id);
|
||||||
if (rgx === null || typeof rgx[1] === 'undefined') {
|
if (rgx === null || typeof rgx[1] === 'undefined') {
|
||||||
|
|
Loading…
Reference in New Issue