Hi

Recently I filed an issue with the Javadoc search in Microsft Edge 
[https://bugs.openjdk.java.net/browse/JDK-8210405]. This was closed as 
unreproducible, but I can consistently reproduce this on multiple PCs.

The problem is as follows: hitting Enter in the search field, selects the first 
result in the autocompletion list. Now, in Microsoft Edge, the autocompletion 
list doesn’t update fast enough, so if you quickly type “String” and hit Enter, 
you won’t be redirected to java.lang.String as expected.
I looked into this myself, and with the changes below, the bug is no longer 
reproducible. Now when you hit Enter, a new search is triggered and the first 
result of this search is used for navigation.
I don’t know if the root cause is a bug in Microsoft Edge, jQuery UI, or the 
Javadoc Search’s usage of jQuery UI, but this shows that there is an issue, and 
that a solution is possible, solely by changing the Javadoc Search 
implementation.

So my question is to reopen this issue and append the given information to it. 
Thanks in advance.

Here’s what I did in search.js:
1) add a global variable:
    var selectRequested = false;

2) inside $("#search").catcomplete(...), change the “select” property by 
extracting the current code into a global function:
    function navigateToItem(ui) {
        // ...
    }

And change the implementation as follows:
    select: function(event, ui) {
        if(event.key === "Enter") {
            selectRequested = true;
            $("#search").catcomplete("search", $("#search").val());
        } else {
            navigateToItem(ui);
        }
    }

3) still inside $("#search").catcomplete(...), change the “response” property 
by appending the following to it:
    if(selectRequested) {
        navigateToItem({item: ui.content[0]});
    }

Kind regards,
Anthony Vanelverdinghe

Reply via email to