diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-08-31 09:32:41 +0300 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-08-31 09:32:41 +0300 |
commit | 90eb9e2b6d3a8333656d672a10fd88aabff95d72 (patch) | |
tree | 584b848cccf55a4addf676cbb765ecca73a5ea12 /app | |
parent | ff5918d3a6c0bbce159c60544138f182c2625692 (diff) | |
parent | 9a93fd9ec4e765873d49c3d8e29ca165b43ba083 (diff) |
Merge branch 'fly-out-nav-jump-fix' into 'master'
Fixed fly-out nav jumping
Closes #36699
See merge request !13690
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/fly_out_nav.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/app/assets/javascripts/fly_out_nav.js b/app/assets/javascripts/fly_out_nav.js index 32cb42c8b10..81697af189b 100644 --- a/app/assets/javascripts/fly_out_nav.js +++ b/app/assets/javascripts/fly_out_nav.js @@ -1,4 +1,3 @@ -import Cookies from 'js-cookie'; import bp from './breakpoints'; const HIDE_INTERVAL_TIMEOUT = 300; @@ -8,9 +7,11 @@ const IS_SHOWING_FLY_OUT_CLASS = 'is-showing-fly-out'; let currentOpenMenu = null; let menuCornerLocs; let timeoutId; +let sidebar; export const mousePos = []; +export const setSidebar = (el) => { sidebar = el; }; export const setOpenMenu = (menu = null) => { currentOpenMenu = menu; }; export const slope = (a, b) => (b.y - a.y) / (b.x - a.x); @@ -20,10 +21,8 @@ let headerHeight = 50; export const getHeaderHeight = () => headerHeight; export const canShowActiveSubItems = (el) => { - const isHiddenByMedia = bp.getBreakpointSize() === 'sm' || bp.getBreakpointSize() === 'md'; - - if (el.classList.contains('active') && !isHiddenByMedia) { - return Cookies.get('sidebar_collapsed') === 'true'; + if (el.classList.contains('active') && (sidebar && !sidebar.classList.contains('sidebar-icons-only'))) { + return false; } return true; @@ -143,13 +142,13 @@ export const documentMouseMove = (e) => { }; export default () => { - const sidebar = document.querySelector('.sidebar-top-level-items'); + sidebar = document.querySelector('.nav-sidebar'); if (!sidebar) return; const items = [...sidebar.querySelectorAll('.sidebar-top-level-items > li')]; - sidebar.addEventListener('mouseleave', () => { + sidebar.querySelector('.sidebar-top-level-items').addEventListener('mouseleave', () => { clearTimeout(timeoutId); timeoutId = setTimeout(() => { |