FIX Do not lose selected id after ENTER the TAB on autocomplete

This commit is contained in:
Laurent Destailleur
2017-10-06 10:46:45 +02:00
parent f0b314dfd7
commit 848aadb48a
2 changed files with 8 additions and 5 deletions

View File

@@ -63,10 +63,13 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
var autoselect = '.$autoselect.'; var autoselect = '.$autoselect.';
var options = '.json_encode($ajaxoptions).'; var options = '.json_encode($ajaxoptions).';
/* Remove product id before select another product use keyup instead of change to avoid loosing the product id. This is needed only for select of predefined product */ /* Remove selected id as soon as we type or delete a char (it means old selection is wrong). Use keyup/down instead of change to avoid loosing the product id. This is needed only for select of predefined product */
/* TODO Check if we can remove this */ $("input#search_'.$htmlname.'").keydown(function(e) {
$("input#search_'.$htmlname.'").keydown(function() { if (e.keyCode != 9) /* If not "Tab" key */
$("#'.$htmlname.'").val(""); {
console.log("Clear id previously selected for field '.$htmlname.'");
$("#'.$htmlname.'").val("");
}
}); });
/* I disable this. A call to trigger is already done later into the select action of the autocomplete code /* I disable this. A call to trigger is already done later into the select action of the autocomplete code

View File

@@ -6378,7 +6378,7 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=')
/** /**
* Set focus onto field with selector * Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
* *
* @param string $selector Selector ('#id' or 'input[name="ref"]') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char. * @param string $selector Selector ('#id' or 'input[name="ref"]') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char.
* @return string HTML code to set focus * @return string HTML code to set focus