From b87d3dbe4b111834cdb9e015fa498bb2634cad47 Mon Sep 17 00:00:00 2001 From: kesselborn Date: Mon, 2 Apr 2018 00:28:26 +0200 Subject: [PATCH] Open top most hit when hitting enter in search form fixes kesselborn/conex#195 --- conex-browser-action.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/conex-browser-action.js b/conex-browser-action.js index 39b6b0b..991ca21 100644 --- a/conex-browser-action.js +++ b/conex-browser-action.js @@ -23,7 +23,7 @@ const keyDownHandling = function(event) { $1('.delete-container-button', event.target).click(); } } else if(event.key == 'Enter') { - console.error('unhandled active element:', document.activeElement); + console.error('unhandled keydown active element:', document.activeElement); return false; } } @@ -45,8 +45,20 @@ const keyPressHandling = function(event) { return; } else if(document.activeElement.dataset.cookieStore) { // a container section bg.switchToContainer(document.activeElement.dataset.cookieStore); + } else if(document.activeElement.id == 'search') { // enter in search form == activate first shown container or tab + for(const e of $('li')) { + if(e.style.display != 'none' && e.dataset.tabId) { + console.log('activateTab', e.dataset.tabId, e); + bg.activateTab(e.dataset.tabId); + break; + } else if(e.style.display != 'none' && e.className == 'section' && e.tabIndex != "-1") { + console.log(`expandTabContainer (tabindex: ${e.tabIndex})`, e.dataset.cookieStore, e); + bg.switchToContainer(e.dataset.cookieStore); + break; + } + } } else { - console.error('unhandled active element:', document.activeElement); + console.error('unhandled keypress active element:', document.activeElement); } window.close(); } catch(e){console.error(e);}