Commit a2f2e203 authored by Mireya Andres's avatar Mireya Andres Committed by Kushal Pandya

Fix top calculation for trigger job page sidebar

parent 39b7314a
...@@ -8,7 +8,6 @@ import CommitBlock from '../../components/commit_block.vue'; ...@@ -8,7 +8,6 @@ import CommitBlock from '../../components/commit_block.vue';
export default { export default {
styles: { styles: {
top: '75px',
width: '290px', width: '290px',
}, },
name: 'BridgeSidebar', name: 'BridgeSidebar',
...@@ -37,17 +36,37 @@ export default { ...@@ -37,17 +36,37 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
topPosition: 0,
};
},
computed: {
rootStyle() {
return { ...this.$options.styles, top: `${this.topPosition}px` };
},
},
mounted() {
this.setTopPosition();
},
methods: { methods: {
onSidebarButtonClick() { onSidebarButtonClick() {
this.$emit('toggleSidebar'); this.$emit('toggleSidebar');
}, },
setTopPosition() {
const navbarEl = document.querySelector('.js-navbar');
if (navbarEl) {
this.topPosition = navbarEl.getBoundingClientRect().bottom;
}
},
}, },
}; };
</script> </script>
<template> <template>
<aside <aside
class="gl-fixed gl-right-0 gl-px-5 gl-bg-gray-10 gl-h-full gl-border-l-solid gl-border-1 gl-border-gray-100 gl-z-index-200 gl-overflow-hidden" class="gl-fixed gl-right-0 gl-px-5 gl-bg-gray-10 gl-h-full gl-border-l-solid gl-border-1 gl-border-gray-100 gl-z-index-200 gl-overflow-hidden"
:style="this.$options.styles" :style="rootStyle"
> >
<div class="gl-py-5 gl-display-flex gl-align-items-center"> <div class="gl-py-5 gl-display-flex gl-align-items-center">
<tooltip-on-truncate :title="bridgeJob.name" truncate-target="child" <tooltip-on-truncate :title="bridgeJob.name" truncate-target="child"
......
...@@ -7,6 +7,14 @@ import { mockCommit, mockJob } from '../mock_data'; ...@@ -7,6 +7,14 @@ import { mockCommit, mockJob } from '../mock_data';
describe('Bridge Sidebar', () => { describe('Bridge Sidebar', () => {
let wrapper; let wrapper;
const MockHeaderEl = {
getBoundingClientRect() {
return {
bottom: '40',
};
},
};
const createComponent = ({ featureFlag } = {}) => { const createComponent = ({ featureFlag } = {}) => {
wrapper = shallowMount(BridgeSidebar, { wrapper = shallowMount(BridgeSidebar, {
provide: { provide: {
...@@ -44,6 +52,17 @@ describe('Bridge Sidebar', () => { ...@@ -44,6 +52,17 @@ describe('Bridge Sidebar', () => {
}); });
}); });
describe('styles', () => {
beforeEach(async () => {
jest.spyOn(document, 'querySelector').mockReturnValue(MockHeaderEl);
createComponent();
});
it('calculates root styles correctly', () => {
expect(wrapper.attributes('style')).toBe('width: 290px; top: 40px;');
});
});
describe('sidebar expansion', () => { describe('sidebar expansion', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
......
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