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(UI): tabsbar dropdown button visibility #305

Open
wants to merge 1 commit 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
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"interactjs": "^1.10.17",
"jquery": "^3.6.0",
"pinia": "^2.0.14",
"resize-observer-polyfill": "^1.5.1",
"vue": "^3.2.25",
"vue-i18n": "^9.1.10",
"vue-router": "^4.0.15",
Expand Down
56 changes: 49 additions & 7 deletions src/components/TabsBar/TabsBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
id="tabsBar"
class="noSelect pointerCursor"
:class="[embedClass(), { maxHeightStyle: showMaxHeight }]"
ref="tabsBar"
>
<draggable
:key="updateCount"
Expand Down Expand Up @@ -46,7 +47,7 @@
<button v-if="!isEmbed()" @click="createNewCircuitScope()">
&#43;
</button>
<button class="tabsbar-toggle" @click="toggleHeight">
<button v-if="isOverflowing" class="tabsbar-toggle" @click="toggleHeight">
<i :class="showMaxHeight ? 'fa fa-chevron-down' : 'fa fa-chevron-up'"></i>
</button>
</div>
Expand All @@ -68,7 +69,7 @@
<script lang="ts" setup>
import draggable from 'vuedraggable'
import { showMessage, truncateString } from '#/simulator/src/utils'
import { ref, Ref } from 'vue'
import { ref, Ref, onBeforeUnmount, onMounted, computed } from 'vue'
import {
createNewCircuitScope,
// deleteCurrentCircuit,
Expand All @@ -79,12 +80,54 @@ import {
// import MessageBox from '#/components/MessageBox/messageBox.vue'
import { useState } from '#/store/SimulatorStore/state'
import { closeCircuit } from '../helpers/deleteCircuit/DeleteCircuit.vue'
import ResizeObserver from 'resize-observer-polyfill';

const SimulatorState = <SimulatorStateType>useState()
const drag: Ref<boolean> = ref(false)
const updateCount: Ref<number> = ref(0)

const showMaxHeight = ref(true)
const tabsBar: Ref<HTMLElement | null> = ref(null);
const tabsBarTotalHeight: Ref<number> = ref(0);
let resizeObserver: ResizeObserver | null = null;
let mutationObserver: MutationObserver | null = null;

const updateTabsBarTotalHeight = () => {
if (tabsBar.value) {
tabsBarTotalHeight.value = tabsBar.value.scrollHeight;
}
};

onMounted(() => {
if (tabsBar.value) {
resizeObserver = new ResizeObserver(updateTabsBarTotalHeight);
resizeObserver.observe(tabsBar.value);

mutationObserver = new MutationObserver(updateTabsBarTotalHeight);
mutationObserver.observe(tabsBar.value, { childList: true, subtree: true});
}
});

onBeforeUnmount(() => {
if (resizeObserver && tabsBar.value) {
resizeObserver.unobserve(tabsBar.value);
resizeObserver = null;
}

if (mutationObserver) {
mutationObserver.disconnect();
mutationObserver = null;
}
});

//To check if the tabs bar is overflowing, for the toggle button
const isOverflowing = computed(() => {
if (tabsBar.value) {
return tabsBar.value.clientHeight < tabsBarTotalHeight.value
}
return false;
});


function toggleHeight() {
showMaxHeight.value = !showMaxHeight.value
Expand Down Expand Up @@ -286,11 +329,11 @@ function isEmbed(): boolean {

<style scoped>
#tabsBar{
padding-right: 50px;
box-sizing: border-box;
position: relative;
overflow: hidden;
padding-bottom: 2.5px;
z-index: 100;
padding-bottom: 2px;
padding-right: 15px;
}

#tabsBar.embed-tabbar {
Expand Down Expand Up @@ -347,7 +390,6 @@ function isEmbed(): boolean {
position: absolute;
right: 2.5px;
top: 2.5px;

display: flex;
justify-content: center;
align-items: center;
Expand All @@ -365,4 +407,4 @@ function isEmbed(): boolean {

</style>

<!-- TODO: add types for scopelist and fix key issue with draggable -->
<!-- TODO: add types for scopelist and fix key issue with draggable -->
Loading