luci-base: cbi: prevent unintended focus on combobox init

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
Jo-Philipp Wich 2016-01-18 20:14:47 +01:00
parent 5eaf4cc489
commit 2bd428ad8a

View file

@ -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) {