Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
465813a2
Commit
465813a2
authored
Aug 30, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes the fly-out navigation flashing in & out
Closes #37022
parent
3e092caa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
4 deletions
+42
-4
app/assets/javascripts/fly_out_nav.js
app/assets/javascripts/fly_out_nav.js
+10
-4
changelogs/unreleased/fly-out-nav-hiding-fix.yml
changelogs/unreleased/fly-out-nav-hiding-fix.yml
+5
-0
spec/javascripts/fly_out_nav_spec.js
spec/javascripts/fly_out_nav_spec.js
+27
-0
No files found.
app/assets/javascripts/fly_out_nav.js
View file @
465813a2
...
...
@@ -12,6 +12,7 @@ let sidebar;
export
const
mousePos
=
[];
export
const
setSidebar
=
(
el
)
=>
{
sidebar
=
el
;
};
export
const
getOpenMenu
=
()
=>
currentOpenMenu
;
export
const
setOpenMenu
=
(
menu
=
null
)
=>
{
currentOpenMenu
=
menu
;
};
export
const
slope
=
(
a
,
b
)
=>
(
b
.
y
-
a
.
y
)
/
(
b
.
x
-
a
.
x
);
...
...
@@ -141,6 +142,14 @@ export const documentMouseMove = (e) => {
if
(
mousePos
.
length
>
6
)
mousePos
.
shift
();
};
export
const
subItemsMouseLeave
=
(
relatedTarget
)
=>
{
clearTimeout
(
timeoutId
);
if
(
!
relatedTarget
.
closest
(
`.
${
IS_OVER_CLASS
}
`
))
{
hideMenu
(
currentOpenMenu
);
}
};
export
default
()
=>
{
sidebar
=
document
.
querySelector
(
'
.nav-sidebar
'
);
...
...
@@ -162,10 +171,7 @@ export default () => {
const
subItems
=
el
.
querySelector
(
'
.sidebar-sub-level-items
'
);
if
(
subItems
)
{
subItems
.
addEventListener
(
'
mouseleave
'
,
()
=>
{
clearTimeout
(
timeoutId
);
hideMenu
(
currentOpenMenu
);
});
subItems
.
addEventListener
(
'
mouseleave
'
,
e
=>
subItemsMouseLeave
(
e
.
relatedTarget
));
}
el
.
addEventListener
(
'
mouseenter
'
,
e
=>
mouseEnterTopItems
(
e
.
currentTarget
));
...
...
changelogs/unreleased/fly-out-nav-hiding-fix.yml
0 → 100644
View file @
465813a2
---
title
:
Fixed fly-out nav flashing in & out
merge_request
:
author
:
type
:
fixed
spec/javascripts/fly_out_nav_spec.js
View file @
465813a2
...
...
@@ -5,12 +5,14 @@ import {
canShowActiveSubItems
,
mouseEnterTopItems
,
mouseLeaveTopItem
,
getOpenMenu
,
setOpenMenu
,
mousePos
,
getHideSubItemsInterval
,
documentMouseMove
,
getHeaderHeight
,
setSidebar
,
subItemsMouseLeave
,
}
from
'
~/fly_out_nav
'
;
import
bp
from
'
~/breakpoints
'
;
...
...
@@ -314,4 +316,29 @@ describe('Fly out sidebar navigation', () => {
).
toBeTruthy
();
});
});
describe
(
'
subItemsMouseLeave
'
,
()
=>
{
beforeEach
(()
=>
{
el
.
innerHTML
=
'
<div class="sidebar-sub-level-items" style="position: absolute;"></div>
'
;
setOpenMenu
(
el
.
querySelector
(
'
.sidebar-sub-level-items
'
));
});
it
(
'
hides subMenu if element is not hovered
'
,
()
=>
{
subItemsMouseLeave
(
el
);
expect
(
getOpenMenu
(),
).
toBeNull
();
});
it
(
'
does not hide subMenu if element is hovered
'
,
()
=>
{
el
.
classList
.
add
(
'
is-over
'
);
subItemsMouseLeave
(
el
);
expect
(
getOpenMenu
(),
).
not
.
toBeNull
();
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment