From 2bd428ad8a76cad41c1d7cf5d6196ca62ab07695 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 18 Jan 2016 20:14:47 +0100 Subject: [PATCH] luci-base: cbi: prevent unintended focus on combobox init Signed-off-by: Jo-Philipp Wich --- modules/luci-base/htdocs/luci-static/resources/cbi.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index fcf87adcb..55e0c4d0a 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -545,7 +545,7 @@ function cbi_bind(obj, type, callback, mode) { return obj; } -function cbi_combobox(id, values, def, man) { +function cbi_combobox(id, values, def, man, focus) { var selid = "cbi.combobox." + id; if (document.getElementById(selid)) { return @@ -605,6 +605,7 @@ function cbi_combobox(id, values, def, man) { cbi_bind(sel, "change", function() { if (sel.selectedIndex == sel.options.length - 1) { obj.style.display = "inline"; + sel.blur(); sel.parentNode.removeChild(sel); obj.focus(); } else { @@ -619,16 +620,18 @@ function cbi_combobox(id, values, def, man) { }) // Retrigger validation in select - sel.focus(); - sel.blur(); + if (focus) { + sel.focus(); + sel.blur(); + } } function cbi_combobox_init(id, values, def, man) { var obj = document.getElementById(id); cbi_bind(obj, "blur", function() { - cbi_combobox(id, values, def, man) + cbi_combobox(id, values, def, man, true); }); - cbi_combobox(id, values, def, man); + cbi_combobox(id, values, def, man, false); } function cbi_filebrowser(id, url, defpath) { -- 2.11.0