You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2021/03/19 13:55:56 UTC
[wicket] branch master updated: WICKET-6867 AutoComplete list don't
choose any item, if click took more then 500 ms
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/master by this push:
new f688376 WICKET-6867 AutoComplete list don't choose any item, if click took more then 500 ms
f688376 is described below
commit f688376e8927ce6d3d6eb74f27ed0f63f08485be
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Fri Mar 19 15:54:10 2021 +0200
WICKET-6867 AutoComplete list don't choose any item, if click took more then 500 ms
Add logic to cancel the hiding of the menu of the mousedown event is on a menu item
---
.../markup/html/autocomplete/wicket-autocomplete.js | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
index 09829c8..7d23fbe 100644
--- a/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
+++ b/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js
@@ -74,6 +74,9 @@
//this is the minimum input length required to display the autocomplete list
var minInputLength = cfg.showListOnEmptyInput === true ? 0 : cfg.minInputLength || 1;
+ // timeout handler that cancels the hiding of the menu if the focus is still on menu items
+ var hideAutoCompleteTimer;
+
function initialize(){
var isShowing = false;
// Remove the autocompletion menu if still present from
@@ -90,11 +93,10 @@
Wicket.Event.add(obj, 'blur', function (jqEvent) {
var menuId=getMenuId();
-
//workaround for IE. Clicks on scrollbar trigger
//'blur' event on input field. (See https://issues.apache.org/jira/browse/WICKET-5882)
if (menuId !== document.activeElement.id && (menuId + "-container") !== document.activeElement.id) {
- window.setTimeout(hideAutoComplete, 500);
+ hideAutoCompleteTimer = window.setTimeout(hideAutoComplete, 500);
} else {
jQuery(this).trigger("focus");
}
@@ -317,7 +319,6 @@
container.appendChild(choiceDiv);
choiceDiv.id=getMenuId();
choiceDiv.className="wicket-aa";
-
}
@@ -432,6 +433,7 @@
}
function hideAutoComplete(){
+ hideAutoCompleteTimer = undefined;
visible = 0;
setSelected(-1);
@@ -634,10 +636,22 @@
render(false, false); // don't scroll - breaks mouse wheel scrolling
showAutoComplete();
};
+
+ var mouseDownFunc = function(event) {
+ // Give a chance the menu's blur event handler to be executed and eventually set
+ // 'hideAutoCompleteTimer'
+ // And then cancel the hiding of the menu
+ window.setTimeout(function() {
+ if (hideAutoCompleteTimer) {
+ window.clearTimeout(hideAutoCompleteTimer);
+ }
+ }, 50);
+ };
for(var i = 0;i < elementCount; i++) {
var node = selectableElements[i];
node.onclick = clickFunc;
node.onmouseover = mouseOverFunc;
+ node.onmousedown = mouseDownFunc;
}
} else {
elementCount=0;