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:56:13 UTC
[wicket] branch wicket-8.x 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 wicket-8.x
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/wicket-8.x by this push:
new d65a675 WICKET-6867 AutoComplete list don't choose any item, if click took more then 500 ms
d65a675 is described below
commit d65a675d2f22726d56c83519a0ad3577bd4ed07d
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
(cherry picked from commit f688376e8927ce6d3d6eb74f27ed0f63f08485be)
---
.../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 c038d3d..8d90aa9 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");
}
@@ -323,7 +325,6 @@
container.appendChild(choiceDiv);
choiceDiv.id=getMenuId();
choiceDiv.className="wicket-aa";
-
}
@@ -438,6 +439,7 @@
}
function hideAutoComplete(){
+ hideAutoCompleteTimer = undefined;
visible = 0;
setSelected(-1);
@@ -640,10 +642,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;