Fix the fly-out menu in the sidebar not displaying in Safari
This commit is contained in:
parent
de0d0e4e47
commit
b5a773923e
7 changed files with 538 additions and 520 deletions
|
@ -15,6 +15,10 @@ export const setOpenMenu = (menu = null) => { currentOpenMenu = menu; };
|
|||
|
||||
export const slope = (a, b) => (b.y - a.y) / (b.x - a.x);
|
||||
|
||||
let headerHeight = 50;
|
||||
|
||||
export const getHeaderHeight = () => headerHeight;
|
||||
|
||||
export const canShowActiveSubItems = (el) => {
|
||||
const isHiddenByMedia = bp.getBreakpointSize() === 'sm' || bp.getBreakpointSize() === 'md';
|
||||
|
||||
|
@ -74,7 +78,7 @@ export const moveSubItemsToPosition = (el, subItems) => {
|
|||
const isAbove = top < boundingRect.top;
|
||||
|
||||
subItems.classList.add('fly-out-list');
|
||||
subItems.style.transform = `translate3d(0, ${Math.floor(top)}px, 0)`; // eslint-disable-line no-param-reassign
|
||||
subItems.style.transform = `translate3d(0, ${Math.floor(top) - headerHeight}px, 0)`; // eslint-disable-line no-param-reassign
|
||||
|
||||
const subItemsRect = subItems.getBoundingClientRect();
|
||||
|
||||
|
@ -153,6 +157,8 @@ export default () => {
|
|||
}, getHideSubItemsInterval());
|
||||
});
|
||||
|
||||
headerHeight = document.querySelector('.nav-sidebar').offsetTop;
|
||||
|
||||
items.forEach((el) => {
|
||||
const subItems = el.querySelector('.sidebar-sub-level-items');
|
||||
|
||||
|
|
|
@ -97,9 +97,9 @@ $new-sidebar-collapsed-width: 50px;
|
|||
top: $header-height;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
overflow: auto;
|
||||
background-color: $gray-normal;
|
||||
box-shadow: inset -2px 0 0 $border-color;
|
||||
transform: translate3d(0, 0, 0);
|
||||
|
||||
&.sidebar-icons-only {
|
||||
width: $new-sidebar-collapsed-width;
|
||||
|
@ -176,6 +176,12 @@ $new-sidebar-collapsed-width: 50px;
|
|||
}
|
||||
}
|
||||
|
||||
.nav-sidebar-inner-scroll {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.with-performance-bar .nav-sidebar {
|
||||
top: $header-height + $performance-bar-height;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) }
|
||||
.nav-sidebar-inner-scroll
|
||||
.context-header
|
||||
= link_to admin_root_path, title: 'Admin Overview' do
|
||||
.avatar-container.s40.settings-avatar
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) }
|
||||
.nav-sidebar-inner-scroll
|
||||
.context-header
|
||||
= link_to group_path(@group), title: @group.name do
|
||||
.avatar-container.s40.group-avatar
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) }
|
||||
.nav-sidebar-inner-scroll
|
||||
.context-header
|
||||
= link_to profile_path, title: 'Profile Settings' do
|
||||
.avatar-container.s40.settings-avatar
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) }
|
||||
.nav-sidebar-inner-scroll
|
||||
- can_edit = can?(current_user, :admin_project, @project)
|
||||
.context-header
|
||||
= link_to project_path(@project), title: @project.name do
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
mousePos,
|
||||
getHideSubItemsInterval,
|
||||
documentMouseMove,
|
||||
getHeaderHeight,
|
||||
} from '~/fly_out_nav';
|
||||
import bp from '~/breakpoints';
|
||||
|
||||
|
@ -59,7 +60,7 @@ describe('Fly out sidebar navigation', () => {
|
|||
|
||||
describe('getHideSubItemsInterval', () => {
|
||||
beforeEach(() => {
|
||||
el.innerHTML = '<div class="sidebar-sub-level-items" style="position: fixed; top: 0; left: 100px; height: 50px;"></div>';
|
||||
el.innerHTML = '<div class="sidebar-sub-level-items" style="position: fixed; top: 0; left: 100px; height: 150px;"></div>';
|
||||
});
|
||||
|
||||
it('returns 0 if currentOpenMenu is nil', () => {
|
||||
|
@ -112,6 +113,7 @@ describe('Fly out sidebar navigation', () => {
|
|||
clientX: el.getBoundingClientRect().left + 20,
|
||||
clientY: el.getBoundingClientRect().top + 10,
|
||||
});
|
||||
console.log(el);
|
||||
|
||||
expect(
|
||||
getHideSubItemsInterval(),
|
||||
|
@ -245,7 +247,7 @@ describe('Fly out sidebar navigation', () => {
|
|||
|
||||
expect(
|
||||
subItems.style.transform,
|
||||
).toBe(`translate3d(0px, ${Math.floor(el.getBoundingClientRect().top)}px, 0px)`);
|
||||
).toBe(`translate3d(0px, ${Math.floor(el.getBoundingClientRect().top) - getHeaderHeight()}px, 0px)`);
|
||||
});
|
||||
|
||||
it('sets is-above when element is above', () => {
|
||||
|
|
Loading…
Reference in a new issue