MR keyboard shortcuts n and p throw a console error if there are no discussions
Summary
When on an MR, pressing the keyboard shortcuts n
or p
trigger a console error reading: TypeError: Cannot destructure property 'id'
Steps to reproduce
- Go to any MR without discussions (or open a new MR)
- Open the developer console
- Press
n
orp
Example Project
Any project on GitLab with an MR that doesn't have any discussions
What is the current bug behavior?
An error is thrown and appears n the developer console.
What is the expected correct behavior?
Keyboard shortcuts that have undefined behavior in certain scenarios should not try to run their code in those scenarios.
In other words: no error.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Possible fixes
The problem is in this function.
There are a number of ways to fix this, but the most effective is probably to interrupt the keyboard shortcuts if the number of discussions is 0 (or 1) and simply never call the discussion navigation functions.
I'm in favor of this because it will protect from a lot of downstream issues if code is running when it doesn't need to be.