Ensure top navbar exists when interacting with the DOM
What does this MR do and why?
This guards a couple places with the optional chaining operator to ensure that the top navbar actually exists before trying to retrieve its height or adding classes to it. This fixes an issue where a commits page would be broken when the super sidebar is enabled. This also affects the IDE, even though it currently does not support the super sidebar.
Screenshots or screen recordings
Before this change, the commit's details page doesn't render properly and and error is logged to the console.
Before | After |
---|---|
How to set up and validate locally
- Navigate to a commit's details page at
/:namespace/-/commit/:sha
. - To enable the new nav:
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.
Related to #392753 (closed)
Edited by Paul Gascou-Vaillancourt