Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25899

Quick search: clicking a suggestion in the header dropdown does nothing in Safari / Firefox on macOS (the dropdown collapses instead of opening the result)

    XMLWordPrintable

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

      1. Open any wiki page in Safari on macOS (Flamingo skin).
      2. Click the search icon in the header and type at least 3 characters (e.g. "wifi").
      3. Wait for the suggestion dropdown to appear.
      4. 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Garbe Christoph
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: