Fix command palette first item lookup under Vue 3

What does this MR do and why?

Fixes a console error in the command palette (super sidebar global search) that appears when GitLab runs on the Vue 3 compat build:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toggle')
  at Proxy.highlightFirstCommand (global_search.vue:407)

highlightFirstCommand() and runFirstCommand() used getFocusableOptions()[0]?.firstChild and assumed the first child node of the .gl-new-dropdown-item list item is the clickable element. Under Vue 3 / @vue/compat, the rendered dropdown item can start with a fragment anchor node — an empty text node or a <!--v-if--> comment. Those nodes have no classList or click(), so highlighting the first command throws, and pressing Enter to run the first command breaks.

References

Screenshots or screen recordings

How to set up and validate locally

  1. Run GDK with the Vue 3 build (VUE_VERSION=3 for webpack).
  2. Open global search and type ~ inside a project to enter file search.
  3. Confirm there is no console error and the first result is highlighted.
  4. Press Enter and confirm the first file opens.
Edited by Chaoyue Zhao

Merge request reports

Loading
Loading