Fixed fly-out error if mousePos array is empty

This commit is contained in:
Phil Hughes 2017-09-18 15:42:41 +01:00
parent 17251d0464
commit c4b2d1878a
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
2 changed files with 7 additions and 1 deletions

View File

@ -34,7 +34,7 @@ export const canShowActiveSubItems = (el) => {
export const canShowSubItems = () => bp.getBreakpointSize() === 'sm' || bp.getBreakpointSize() === 'md' || bp.getBreakpointSize() === 'lg';
export const getHideSubItemsInterval = () => {
if (!currentOpenMenu) return 0;
if (!currentOpenMenu || mousePos.length >= 1) return 0;
const currentMousePos = mousePos[mousePos.length - 1];
const prevMousePos = mousePos[0];

View File

@ -73,6 +73,12 @@ describe('Fly out sidebar navigation', () => {
).toBe(0);
});
it('returns 0 if mousePos is empty', () => {
expect(
getHideSubItemsInterval(),
).toBe(0);
});
it('returns 0 when mouse above sub-items', () => {
showSubLevelItems(el);
documentMouseMove({