Commit aae23494 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch 'safari-fly-out-fix' into 'master'

Fix the fly-out menu in the sidebar not displaying in Safari

Closes #36441

See merge request !13445
parents efa996d7 b5a77392
...@@ -15,6 +15,10 @@ export const setOpenMenu = (menu = null) => { currentOpenMenu = menu; }; ...@@ -15,6 +15,10 @@ export const setOpenMenu = (menu = null) => { currentOpenMenu = menu; };
export const slope = (a, b) => (b.y - a.y) / (b.x - a.x); export const slope = (a, b) => (b.y - a.y) / (b.x - a.x);
let headerHeight = 50;
export const getHeaderHeight = () => headerHeight;
export const canShowActiveSubItems = (el) => { export const canShowActiveSubItems = (el) => {
const isHiddenByMedia = bp.getBreakpointSize() === 'sm' || bp.getBreakpointSize() === 'md'; const isHiddenByMedia = bp.getBreakpointSize() === 'sm' || bp.getBreakpointSize() === 'md';
...@@ -74,7 +78,7 @@ export const moveSubItemsToPosition = (el, subItems) => { ...@@ -74,7 +78,7 @@ export const moveSubItemsToPosition = (el, subItems) => {
const isAbove = top < boundingRect.top; const isAbove = top < boundingRect.top;
subItems.classList.add('fly-out-list'); 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(); const subItemsRect = subItems.getBoundingClientRect();
...@@ -153,6 +157,8 @@ export default () => { ...@@ -153,6 +157,8 @@ export default () => {
}, getHideSubItemsInterval()); }, getHideSubItemsInterval());
}); });
headerHeight = document.querySelector('.nav-sidebar').offsetTop;
items.forEach((el) => { items.forEach((el) => {
const subItems = el.querySelector('.sidebar-sub-level-items'); const subItems = el.querySelector('.sidebar-sub-level-items');
......
...@@ -97,9 +97,9 @@ $new-sidebar-collapsed-width: 50px; ...@@ -97,9 +97,9 @@ $new-sidebar-collapsed-width: 50px;
top: $header-height; top: $header-height;
bottom: 0; bottom: 0;
left: 0; left: 0;
overflow: auto;
background-color: $gray-normal; background-color: $gray-normal;
box-shadow: inset -2px 0 0 $border-color; box-shadow: inset -2px 0 0 $border-color;
transform: translate3d(0, 0, 0);
&.sidebar-icons-only { &.sidebar-icons-only {
width: $new-sidebar-collapsed-width; width: $new-sidebar-collapsed-width;
...@@ -176,6 +176,12 @@ $new-sidebar-collapsed-width: 50px; ...@@ -176,6 +176,12 @@ $new-sidebar-collapsed-width: 50px;
} }
} }
.nav-sidebar-inner-scroll {
height: 100%;
width: 100%;
overflow: auto;
}
.with-performance-bar .nav-sidebar { .with-performance-bar .nav-sidebar {
top: $header-height + $performance-bar-height; top: $header-height + $performance-bar-height;
} }
......
.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) } .nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) }
.nav-sidebar-inner-scroll
.context-header .context-header
= link_to admin_root_path, title: 'Admin Overview' do = link_to admin_root_path, title: 'Admin Overview' do
.avatar-container.s40.settings-avatar .avatar-container.s40.settings-avatar
......
.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) } .nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) }
.nav-sidebar-inner-scroll
.context-header .context-header
= link_to group_path(@group), title: @group.name do = link_to group_path(@group), title: @group.name do
.avatar-container.s40.group-avatar .avatar-container.s40.group-avatar
......
.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) } .nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) }
.nav-sidebar-inner-scroll
.context-header .context-header
= link_to profile_path, title: 'Profile Settings' do = link_to profile_path, title: 'Profile Settings' do
.avatar-container.s40.settings-avatar .avatar-container.s40.settings-avatar
......
.nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) } .nav-sidebar{ class: ("sidebar-icons-only" if collapsed_sidebar?) }
.nav-sidebar-inner-scroll
- can_edit = can?(current_user, :admin_project, @project) - can_edit = can?(current_user, :admin_project, @project)
.context-header .context-header
= link_to project_path(@project), title: @project.name do = link_to project_path(@project), title: @project.name do
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
mousePos, mousePos,
getHideSubItemsInterval, getHideSubItemsInterval,
documentMouseMove, documentMouseMove,
getHeaderHeight,
} from '~/fly_out_nav'; } from '~/fly_out_nav';
import bp from '~/breakpoints'; import bp from '~/breakpoints';
...@@ -59,7 +60,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -59,7 +60,7 @@ describe('Fly out sidebar navigation', () => {
describe('getHideSubItemsInterval', () => { describe('getHideSubItemsInterval', () => {
beforeEach(() => { 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', () => { it('returns 0 if currentOpenMenu is nil', () => {
...@@ -112,6 +113,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -112,6 +113,7 @@ describe('Fly out sidebar navigation', () => {
clientX: el.getBoundingClientRect().left + 20, clientX: el.getBoundingClientRect().left + 20,
clientY: el.getBoundingClientRect().top + 10, clientY: el.getBoundingClientRect().top + 10,
}); });
console.log(el);
expect( expect(
getHideSubItemsInterval(), getHideSubItemsInterval(),
...@@ -245,7 +247,7 @@ describe('Fly out sidebar navigation', () => { ...@@ -245,7 +247,7 @@ describe('Fly out sidebar navigation', () => {
expect( expect(
subItems.style.transform, 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', () => { it('sets is-above when element is above', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment