[bug] fix auto suggest up and down keyboard navigation

This commit is contained in:
zombieFox 2020-08-12 07:40:33 +01:00
parent 008694baf0
commit 4aabcd5b5c
5 changed files with 9 additions and 8 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "nightTab",
"version": "6.1.0",
"version": "6.1.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "nightTab",
"version": "6.1.0",
"version": "6.1.1",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"main": "index.js",
"scripts": {

View File

@ -52,6 +52,7 @@ var autoSuggest = (function() {
var elementToFocus = null;
var focusIndex = null;
var allSuggestItems = helper.eA(".auto-suggest-item");
var columnCount = getComputedStyle(helper.e(".auto-suggest-list")).getPropertyValue("grid-template-columns").split(" ").length;
var _findInput = function() {
if (event.target.classList.contains("auto-suggest-input")) {
_currentInputOptions.input = event.target;
@ -71,8 +72,8 @@ var autoSuggest = (function() {
if (focusIndex == null) {
elementToFocus = allSuggestItems[allSuggestItems.length - 1];
} else {
if (focusIndex > 2 && focusIndex <= allSuggestItems.length - 1) {
elementToFocus = allSuggestItems[focusIndex - 3];
if (focusIndex >= columnCount && focusIndex <= allSuggestItems.length - 1) {
elementToFocus = allSuggestItems[focusIndex - columnCount];
} else {
elementToFocus = _currentInputOptions.input;
};
@ -84,8 +85,8 @@ var autoSuggest = (function() {
if (focusIndex == null) {
elementToFocus = allSuggestItems[0];
} else {
if (focusIndex < allSuggestItems.length - 3) {
elementToFocus = allSuggestItems[focusIndex + 3];
if (focusIndex < allSuggestItems.length - columnCount) {
elementToFocus = allSuggestItems[focusIndex + columnCount];
} else {
elementToFocus = _currentInputOptions.input;
};

View File

@ -1,6 +1,6 @@
var version = (function() {
var current = "6.1.0";
var current = "6.1.1";
var name = "Jaded Raven";

View File

@ -2,7 +2,7 @@
"name": "nightTab",
"short_name": "nightTab",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"version": "6.1.0",
"version": "6.1.1",
"manifest_version": 2,
"chrome_url_overrides": {
"newtab": "index.html"