Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
18.9.0
-
None
-
XWiki 18.9.0, Flamingo skin, macOS, Safari 27.2 (22625.2.8.11.9); also expected in Firefox on macOS (not tested). Chrome is not affected.
-
Unknown
-
Description
Steps to reproduce
- Open any wiki page in Safari on macOS (Flamingo skin).
- Click the search icon in the header and type at least 3 characters (e.g. "wifi").
- Wait for the suggestion dropdown to appear.
- Click on one of the suggested pages or attachments with the mouse.
Expected result
The browser navigates to the clicked page / attachment.
Actual result
The search field collapses, the dropdown slides away and disappears, and no navigation happens. Keyboard selection (arrow keys + Enter) still works. In Chrome the same click works.
Analysis
The quick search closes itself when the focus leaves #globalsearch (XWiki.QuickSearchUIX):
a.on('focusout', function () { setTimeout(function () { document.getElementById('globalsearch').contains(document.activeElement) || e(); }, 1); });
e() adds globalsearch-close and fires xwiki:suggest:collapsed; searchSuggest.js then calls resetTimeout() so the suggestions get cleared.
Chrome moves the focus to the suggestion link on mousedown, so document.activeElement stays inside #globalsearch and nothing happens. Safari (and Firefox on macOS) do not focus links on click (deliberate WebKit behaviour, see https://bugs.webkit.org/show_bug.cgi?id=312692), so on mousedown the focus goes to <body> and the collapse starts right away, before the click completes.
Measured in the browser after the input loses focus (simulated with blur()):
- the .suggestItems container slides ~200px to the right during the 0.3s width transition of #headerglobalsearchinput,
- the container is removed from the DOM after ~1s.
By mouseup the link has moved away from under the pointer, so no click event is dispatched on it.
Related: XWIKI-22148 (introduced hiding the results on focus loss), XWIKI-22957 (Ctrl+Click on quick search links).
Workaround / possible fix
Prevent the mousedown inside the dropdown from moving the focus out of the input, e.g. in searchSuggest.js or as a JSX:
document.addEventListener('mousedown', function (e) { if (e.target.closest && e.target.closest('#globalsearch .suggestItems')) { e.preventDefault(); } }, true);
Alternatively, ignore a focusout whose relatedTarget is null while a pointer interaction inside #globalsearch is in progress.