Browse Source

Set focus on article link when pressing prev/next hotkeys

This enhancement offer the possibility to open articles in the background by using the browser hotkey Ctrl+Return or Cmd+Return.
Diego Agulló 7 years ago
parent
commit
98206059fc
2 changed files with 8 additions and 4 deletions
  1. 4 4
      ui/static/js.go
  2. 4 0
      ui/static/js/nav_handler.js

File diff suppressed because it is too large
+ 4 - 4
ui/static/js.go


+ 4 - 0
ui/static/js/nav_handler.js

@@ -167,6 +167,7 @@ class NavHandler {
 
         if (document.querySelector(".current-item") === null) {
             items[0].classList.add("current-item");
+            items[0].querySelector('.item-header a').focus();
             return;
         }
 
@@ -177,6 +178,7 @@ class NavHandler {
                 if (i - 1 >= 0) {
                     items[i - 1].classList.add("current-item");
                     DomHelper.scrollPageTo(items[i - 1]);
+                    items[i - 1].querySelector('.item-header a').focus();
                 }
 
                 break;
@@ -193,6 +195,7 @@ class NavHandler {
 
         if (currentItem === null) {
             items[0].classList.add("current-item");
+            items[0].querySelector('.item-header a').focus();
             return;
         }
 
@@ -203,6 +206,7 @@ class NavHandler {
                 if (i + 1 < items.length) {
                     items[i + 1].classList.add("current-item");
                     DomHelper.scrollPageTo(items[i + 1]);
+                    items[i + 1].querySelector('.item-header a').focus();
                 }
 
                 break;

Some files were not shown because too many files changed in this diff