Loading
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
- Review thread where the bug was reported: !250742 (comment 3712917080)
Screenshots or screen recordings
How to set up and validate locally
- Run GDK with the Vue 3 build (
VUE_VERSION=3for webpack). - Open global search and type
~inside a project to enter file search. - Confirm there is no console error and the first result is highlighted.
- Press Enter and confirm the first file opens.
Edited by Chaoyue Zhao