Fix keyboard shortcuts modal in super sidebar
What does this MR do and why?
This fixes the keyboard shortcuts menu item in super sidebar. On certain pages (e.g., any project page, like a merge request or issues list), the button did nothing except log an error:
TypeError: t.toggleShortcutsHelp is not a function
The help button was added in
!109385 (merged), but it
wasn't working on certain pages, specifically those listed in
~/behaviors/shortcuts.js
.
This removes the global function defined on pages other than those listed above. Instead, we now rely on event delegation in the Shortcuts class for detecting the clicks to the shortcuts modal trigger, since the sidebar might not be in the DOM by the time the Shortcuts constructor (or some subclass of it) is called.
Screenshots or screen recordings
n/a
How to set up and validate locally
- Enable the
super_sidebar_nav
feature flag - Enable the new navigation user preference
- Visit any page listed in
~/behaviors/shortcuts.js#L4-24
- Click the Help > Keyboard shortcuts button in the sidebar
- Observe the shortcuts modal appears
- Repeat steps 2 to 4 inclusive for a page not listed above (e.g., the Explore dashboard, or To-Dos)
- Check all of the above still works when the new navigation user preference is disabled
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.