Skip to content

Ensure top navbar exists when interacting with the DOM

Paul Gascou-Vaillancourt requested to merge 392753-new-nav-offsetheight-bug into master

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
Screenshot_2023-02-21_at_1.34.37_PM Screenshot_2023-02-21_at_1.34.13_PM

How to set up and validate locally

  1. Navigate to a commit's details page at /:namespace/-/commit/:sha.
  2. To enable the new nav:
    1. Enable the feature flag:

      echo "Feature.enable(:super_sidebar_nav)" | rails c
    2. Enable the user setting from the user dropdown:

      Screenshot_2022-12-13_at_1.32.43_PM

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #392753 (closed)

Edited by Paul Gascou-Vaillancourt

Merge request reports