On Wed, 4 Mar 2026 17:21:57 GMT, Hannes Wallnöfer <[email protected]> wrote:

> Please review a change to replace the jQuery-UI autocomplete component in 
> JavaDoc search with our own search widget previously used only in the search 
> page. The new search widget adds a few new features:
> 
>  - Tabbed table interface to easily switch between element categories (types, 
> members, packages etc.)
>  - Module selector to limit search to individual modules in multi-module 
> documentation bundles
>  - No dependency on jQuery-UI or jQuery as the code is written in plain 
> JavaScript
>  - Single search implementation for both search page and navigation bar 
> search widget
> 
> The code for the search widget, which previously lived in `search-page.js`  
> and was used for the search page (`search.html`) only, is converted from 
> jQuery to plain JavaScript and moved to `search.js.template`. 
> `search-page.js` as well as all jQuery JavaScript and CSS files are deleted 
> as they are no longer needed. 
> 
> Keyboard navigation of search results differs from the jQueryUI autocomplete 
> component, as using the Tab key to open the selected result is problematic 
> for users of keyboard navigation who rely on the Tab key as primary means to 
> move focus. Instead, keyboard navigation uses the arrow keys to move through 
> result items and tabs, and the Enter key to open the selected result item.
> 
> The new search widget [can be tested 
> here](https://cr.openjdk.org/~hannesw/8378228/api.02/) with the Java SE/JDK 
> API docs.

I left a couple inline comments.

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js.template
 line 100:

> 98:             urlPrefix = item.m + slash;
> 99:         } else {
> 100:             packageSearchIndex.forEach(function(it) {

I'm not a js expert but I beliebe `return false` will not break out of 
`Arrays.foreach` so instead of returning the first match it will keep looking 
for matches.

I suppose this could also make the code a little slower or it could return the 
second match if we have two packages with the same name in two different 
modules.

https://stackoverflow.com/questions/2641347/short-circuit-array-foreach-like-calling-break
https://codingnomads.com/break-out-of-foreach-javascript#:~:text=forEach()%20is%20not%20designed,the%20return%20value%20is%20ignored.

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js.template
 line 621:

> 619:             activeTab = category;
> 620: 
> 621:             $$("div.result-table", resultContainer).forEach(el => 
> el.remove());

If I go to `https://cr.openjdk.org/~hannesw/8378228/api.02/search.html?q=List` 
and click on the "Members" tab, the URL does not change. So if I refresh the 
page it goes back to the default tab.
Compared to 
`https://download.java.net/java/early_access/jdk27/docs/api/search.html?q=List` 
where clicking on an other tab changes the URL to 
`https://download.java.net/java/early_access/jdk27/docs/api/search.html?q=List&c=members`.

The old `search-page.js` updated the query string whenever a tab was clicked.

-------------

Changes requested by nbenalla (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/30057#pullrequestreview-4075822637
PR Review Comment: https://git.openjdk.org/jdk/pull/30057#discussion_r3052060832
PR Review Comment: https://git.openjdk.org/jdk/pull/30057#discussion_r3051987876

Reply via email to