Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Modified z-index for draggable components, navbar and tabsBar in both expanded and collapsed states of tabsBar #261

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 58 additions & 3 deletions src/components/Navbar/NavbarLinks/NavbarLink/NavbarLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
role="button"
aria-haspopup="true"
aria-expanded="false"
@click="toggleDropdown"
>
{{ $t('simulator.nav.' + navbarItem.text + '.heading') }}
<span></span>
Expand All @@ -21,11 +22,65 @@
</template>

<script lang="ts" setup>
import DropDown from '@/Dropdown/DropDown.vue'
import { onBeforeUnmount, onMounted, ref } from 'vue';
import DropDown from '@/Dropdown/DropDown.vue';

const props = defineProps({
navbarItem: { type: Object, default: () => {} },
})
navbarItem: { type: Object, default: () => {} },
});

const isDropdownOpen = ref(false);

const toggleDropdown = () => {
isDropdownOpen.value = !isDropdownOpen.value;

const navbar = document.querySelector('.navbar');
const tabsBar = document.getElementById('tabsBar');
let isTabsBarExpaned = !tabsBar.classList.contains('maxHeightStyle')

if (!isDropdownOpen.value && !isTabsBarExpaned) {
navbar.style.zIndex = '';
tabsBar.style.zIndex = '';
} else {
navbar.style.zIndex = '103';
tabsBar.style.zIndex = '102';
}
};

const handleDocumentClick = (event) => {
const dropdownElements = Array.from(document.querySelectorAll('.nav-dropdown a'));

const tabsBarToggleButton = document.querySelector('.tabsbar-toggle');
let istabsBarToggleClicked = tabsBarToggleButton?.contains(event.target);

const isClickInsideDropdown = dropdownElements.some((dropdownElement) => {
return dropdownElement.contains(event.target);
});

if (!isClickInsideDropdown) {
isDropdownOpen.value = false;

if(istabsBarToggleClicked) return;

const navbar = document.querySelector('.navbar');
const tabsBar = document.getElementById('tabsBar');
let isTabsBarExpaned = !tabsBar.classList.contains('maxHeightStyle')

if (!isDropdownOpen.value && !isTabsBarExpaned) {
navbar.style.zIndex = '';
tabsBar.style.zIndex = '';
}
}
}

onMounted(() => {
window.addEventListener('click', handleDocumentClick);
});

onBeforeUnmount(() => {
window.removeEventListener('click', handleDocumentClick);
});

</script>

<style scoped>
Expand Down
13 changes: 12 additions & 1 deletion src/components/TabsBar/TabsBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ const showMaxHeight = ref(true)

function toggleHeight() {
showMaxHeight.value = !showMaxHeight.value

const navbar = document.querySelector('.navbar');
const tabsBar = document.getElementById('tabsBar');

if (showMaxHeight.value) {
navbar.style.zIndex = '';
tabsBar.style.zIndex = '';
} else {
navbar.style.zIndex = '103';
tabsBar.style.zIndex = '102';
}
}

// const persistentShow: Ref<boolean> = ref(false)
Expand Down Expand Up @@ -289,7 +300,7 @@ function isEmbed(): boolean {
position: relative;
overflow: hidden;
padding-bottom: 2.5px;
z-index: 100;
z-index: 99;
}

#tabsBar.embed-tabbar {
Expand Down
4 changes: 2 additions & 2 deletions src/simulator/src/drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export function dragging(targetEl: HTMLElement, DragEl: HTMLElement): void {
})

$(DragEl).on('mousedown', () => {
$(`.draggable-panel:not(${DragEl})`).css('z-index', '99')
$(DragEl).css('z-index', '99')
$(`.draggable-panel:not(${DragEl})`).css('z-index', '100')
$(DragEl).css('z-index', '101')
})

let panelElements = document.querySelectorAll(
Expand Down
Loading