From e180390ae1ec9c594e6be9296fb2ee3f6942975d Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 4 Feb 2019 13:38:44 +0000 Subject: [PATCH 1/2] [FIX] web_responsive: Skip re-search when not writing When the user uses TAB or SHIFT+TAB to navigate in search results, he can trigger a SHIFT-only keydown event without noticing, which would reset the selected result position to the first or last. It is disturbing, so, to avoid that problem, the re-search is only triggered if the currently pressed key has length=1 or is Backspace, which will skip most keys that are not actually writing a character into the search input, like i.e. "Shift", "Alt", "F4", etc. In addition to that, to detect if the search results is empty, the `:empty` selector is not trustable because it considers not empty nodes with whitespace-only content. That has been patched too. --- web_responsive/static/src/js/web_responsive.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web_responsive/static/src/js/web_responsive.js b/web_responsive/static/src/js/web_responsive.js index 8bd94cc3..cca88b59 100644 --- a/web_responsive/static/src/js/web_responsive.js +++ b/web_responsive/static/src/js/web_responsive.js @@ -217,7 +217,7 @@ odoo.define('web_responsive', function (require) { */ _searchResultsNavigate: function (event) { // Exit soon when not navigating results - if (this.$search_results.is(":empty")) { + if (this.$search_results.html().trim() === "") { // Just in case it is the 1st search this._searchMenusSchedule(); return; @@ -227,7 +227,7 @@ odoo.define('web_responsive', function (require) { pre_focused = all.filter(".active") || $(all[0]), offset = all.index(pre_focused), key = event.key; - // Transform tab presses in arrow presses + // Transform tab presses in arrow presses if (key === "Tab") { event.preventDefault(); key = event.shiftKey ? "ArrowUp" : "ArrowDown"; @@ -246,7 +246,10 @@ odoo.define('web_responsive', function (require) { break; // Other keys trigger a search default: - this._searchMenusSchedule(); + // All keys that write a character have length 1 + if (key.length === 1 || key === "Backspace") { + this._searchMenusSchedule(); + } return; } // Allow looping on results From 7692f52c770bf6d6962764e29812623729a6409a Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Mon, 4 Feb 2019 13:40:47 +0000 Subject: [PATCH 2/2] [FIX] web_responsive: Make app icons and search results middle-button-clickable In the case of app icons, those weren't getting the `href` attribute filled. In the case of search results, those weren't even an `` element. Fixed in both cases to fix https://github.com/OCA/web/issues/1170. --- web_responsive/static/src/xml/apps.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web_responsive/static/src/xml/apps.xml b/web_responsive/static/src/xml/apps.xml index b5a14bb5..9a277ecc 100644 --- a/web_responsive/static/src/xml/apps.xml +++ b/web_responsive/static/src/xml/apps.xml @@ -4,6 +4,11 @@