NEW No auto open keyboard on smartphone when opening list of columns

This commit is contained in:
ldestailleur
2025-03-24 12:48:38 +01:00
parent 5096063676
commit 920c84a056
5 changed files with 40 additions and 29 deletions

View File

@@ -867,8 +867,7 @@ class Form
if (!empty($conf->use_javascript_ajax)) {
$ret .= '<!-- JS CODE TO ENABLE mass action select -->
<script nonce="' . getNonce() . '">
function initCheckForSelect(mode, name, cssclass) /* mode is 0 during init of page or click all, 1 when we click on 1 checkboxi, "name" refers to the class of the massaction button, "cssclass" to the class of the checkfor select boxes */
{
function initCheckForSelect(mode, name, cssclass) { /* mode is 0 during init of page or click all, 1 when we click on 1 checkboxi, "name" refers to the class of the massaction button, "cssclass" to the class of the checkfor select boxes */
atleastoneselected=0;
jQuery("."+cssclass).each(function( index ) {
/* console.log( index + ": " + $( this ).text() ); */
@@ -877,14 +876,11 @@ class Form
console.log("initCheckForSelect mode="+mode+" name="+name+" cssclass="+cssclass+" atleastoneselected="+atleastoneselected);
if (atleastoneselected || ' . ((int) $alwaysvisible) . ')
{
if (atleastoneselected || ' . ((int) $alwaysvisible) . ') {
jQuery("."+name).show();
' . ($selected ? 'if (atleastoneselected) { jQuery("."+name+"select").val("' . $selected . '").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', false); }' : '') . '
' . ($selected ? 'if (! atleastoneselected) { jQuery("."+name+"select").val("0").trigger(\'change\'); jQuery("."+name+"confirmed").prop(\'disabled\', true); } ' : '') . '
}
else
{
} else {
jQuery("."+name).hide();
jQuery("."+name+"other").hide();
}
@@ -9605,7 +9601,7 @@ class Form
*/
public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage, $pos = '')
{
global $langs, $user;
global $conf, $langs, $user;
if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
return '';
@@ -9658,7 +9654,9 @@ class Form
// Note: $val['checked'] <> 0 means we must show the field into the combo list @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset
$listoffieldsforselection .= '<li><input type="checkbox" id="checkbox' . $key . '" value="' . $key . '"' . ((!array_key_exists('checked', $val) || empty($val['checked']) || $val['checked'] == '-1') ? '' : ' checked="checked"') . ' data-position="'.(empty($val['position']) ? '' : $val['position']).'" />';
$listoffieldsforselection .= '<label for="checkbox' . $key . '">'.dol_string_nohtmltag($langs->trans($val['label'])) . '</label></li>';
$listoffieldsforselection .= '<label for="checkbox' . $key . '">';
$listoffieldsforselection .= dolPrintHTML(dol_string_nohtmltag($langs->trans($val['label'])));
$listoffieldsforselection .= '</label></li>';
$listcheckedstring .= (empty($val['checked']) ? '' : $key . ',');
}
}
@@ -9675,7 +9673,9 @@ class Form
<dd class="dropdowndd">
<div class="multiselectcheckbox'.$htmlname.'">
<ul class="'.$htmlname.($pos == '1' ? 'left' : '').'">
<li class="liinputsearch"><input class="inputsearch_dropdownselectedfields width90p minwidth200imp" style="width:90%;" type="text" placeholder="'.$langs->trans('Search').'"></li>
<li class="liinputsearch">
<input class="inputsearch_dropdownselectedfields width90p minwidth200imp" style="width:90%;" type="text" placeholder="'.$langs->trans('Search').'">
</li>
'.$listoffieldsforselection.'
</ul>
</div>
@@ -9684,7 +9684,7 @@ class Form
<script nonce="' . getNonce() . '" type="text/javascript">
jQuery(document).ready(function () {
$(\'.multiselectcheckbox' . $htmlname . ' input[type="checkbox"]\').on(\'click\', function () {
$(\'.multiselectcheckbox' . $htmlname . ' input[type="checkbox"]\').on("click", function () {
console.log("A new field was added/removed, we edit field input[name=formfilteraction]");
$("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\'); // Update field so we know we changed something on selected fields after POST
@@ -9699,14 +9699,23 @@ class Form
// Now, we submit page
//$(this).parents(\'form:first\').submit();
});
$("input.inputsearch_dropdownselectedfields").on("keyup", function() {
console.log("keyup on inputsearch_dropdownselectedfields");
var value = $(this).val().toLowerCase();
$(\'.multiselectcheckbox'.$htmlname.' li > label\').filter(function() {
$(this).parent().toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
';
if (empty($conf->browser->layout) || $conf->browser->layout != 'phone') {
$out .= '
$(".dropdown dt a").on("click", function () {
console.log("Click on dropdown, we set focus to search field");
setTimeout(() => { $(\'.inputsearch_dropdownselectedfields\').focus(); }, 200);
});';
}
$out .= '
});
</script>

View File

@@ -165,7 +165,6 @@ if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) {
// Click onto the link "link to" or "hamburger", toggle dropdown
$(document).on(\'click\', \'.dropdown dt a\', function () {
console.log("toggle dropdown dt a");
setTimeout(() => { $(\'.inputsearch_dropdownselectedfields\').focus(); }, 200);
//$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\');
$(".ulselectedfields").removeClass("open");

View File

@@ -1549,7 +1549,7 @@ if (!getDolGlobalString('MAIN_DISABLE_SELECT2_FOCUS_PROTECTION') && !defined('DI
?>
/*
* Hacky fix for a bug in select2 with jQuery 3.6.4's new nested-focus "protection"
* This fix needs to click a second time when clicking into a combo with ajax (see Test4d and Test5a in test_forms.php
* This fix the need to click a second time when clicking into a combo with ajax (see Test4d and Test5a in test_forms.php
* see: https://github.com/select2/select2/issues/5993
* see: https://github.com/jquery/jquery/issues/4382
*

View File

@@ -11956,7 +11956,7 @@ function dolExplodeKeepIfQuotes($input)
function dol_set_focus($selector)
{
print "\n".'<!-- Set focus onto a specific field -->'."\n";
print '<script nonce="'.getNonce().'">jQuery(document).ready(function() { jQuery("'.dol_escape_js($selector).'").focus(); });</script>'."\n";
print '<script nonce="'.getNonce().'">jQuery(document).ready(function() { console.log("Force focus by dol_set_focus"); jQuery("'.dol_escape_js($selector).'").focus(); });</script>'."\n";
}

View File

@@ -2635,7 +2635,6 @@ function top_menu_quickadd()
var openQuickAddDropDown = function(event) {
event.preventDefault();
$("#topmenu-quickadd-dropdown").toggleClass("open");
//$("#top-quickadd-search-input").focus();
}
});
</script>
@@ -2967,6 +2966,7 @@ function top_menu_bookmark()
});
var openBookMarkDropDown = function(event) {
console.log("toggle #topmenu-bookmark-dropdown and force focus");
event.preventDefault();
jQuery("#topmenu-bookmark-dropdown").toggleClass("open");
jQuery("#top-bookmark-search-input").focus();
@@ -3071,6 +3071,7 @@ function top_menu_search()
if (e.keyCode == 13 || e.keyCode == 40) {
var inputs = $(this).parents("form").eq(0).find(":button");
if (inputs[inputs.index(this) + 1] != null) {
console.log("Force focus after keydow on #top-global-search-input");
inputs[inputs.index(this) + 1].focus();
if (e.keyCode == 13){
inputs[inputs.index(this) + 1].trigger("click");
@@ -3091,12 +3092,14 @@ function top_menu_search()
// UP - move to the previous line
if (e.keyCode == 38) {
e.preventDefault();
console.log("Force focus after keycode 38");
$focused.prev().focus();
}
// DOWN - move to the next line
if (e.keyCode == 40) {
e.preventDefault();
console.log("Force focus after keycode 40");
$focused.next().focus();
}
}