Consolidate keyboard logic and consider exposing it in a reusable way

Follow-up to gitlab-org/gitlab!115057 (comment 1321522714)

We repeat the same keyboard logic multiple times in GitLab UI for dropdown type components.

We also sometimes need this keyboard logic outside of GitLab UI. For example we are creating a global search modal in gitlab-org/gitlab!115057 (merged) but can't use the Listbox component because it is always tied to the toggle button which we don't want. This means that we need to copy the keyboard logic from GitLab UI.

A couple of options:

  1. Move keyboard logic to src/components/base/new_dropdowns/base_dropdown/base_dropdown.vue
    • If we went this route it would also be nice to extract the toggle button out of this component. Then we could use this component more moduly for things like the global search modal in gitlab-org/gitlab!115057 (merged)
  2. Move the keyboard logic to a util so it can be used in multiple components. Consider exposing this new util so it can be used outside of GitLab UI
Edited by Mark Florian