New navigation breaks commit pages in several ways
If you visit a commit page (e.g., gitlab-ui@c95606f6) with the new navigation enabled, several things break:
Old navigation | New navigation |
---|---|
- The commit details never seem to load.
- The header bar for the first file is split/broken.
- The code is not syntax highlighted correctly.
- The diff stat and file selector are missing.
It might be that something is checking for the offsetHeight
of the old top nav, and doesn't handle it not being found, causing some script to abort early? If that's the case, it's feasible this affects other pages as well.
Cause
This is caused by app/assets/javascripts/pages/projects/commit/show/index.js#L23 where we attempt to retrieve the topbar's offsetHeight
without ensuring that the topbar actually exists. We do similar operations in several places, but we generally abort the execution if the querySelector
fails to find the topbar.
Solution
We should be able to quickly fix the affect place(s) by leveraging the optional chaining operator and falling back to a height of 0
when the topbar is not rendered.