Skip to content

Commit a6cce01

Browse files
Adding check for slot content to hide column to avoid unnecessary space
1 parent e75a27a commit a6cce01

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/plugin/slots/TopSlot.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
/>
77

88
<v-col
9-
v-else-if="showSearch || slots[`top.left`] || slots[`top.right`]"
9+
v-else-if="(showSearch || slots[`top.left`] || slots[`top.right`]) && showTopContent"
1010
lg="12"
1111
>
12-
<v-row>
12+
<v-row :data-id="`vdt-top-id-${props.level}`">
1313
<slot
1414
v-if="slots[`top.left`]"
1515
name="top.left"
@@ -59,7 +59,6 @@ const emit = defineEmits([
5959
'update:search',
6060
]);
6161
62-
6362
const props = withDefaults(defineProps<TopSlotProps>(), {
6463
searchProps: () => ({
6564
cols: {
@@ -76,6 +75,7 @@ const props = withDefaults(defineProps<TopSlotProps>(), {
7675
});
7776
7877
const levelSearch = ref<string>('');
78+
const showTopContent = ref<boolean>(true);
7979
8080
const tableItems = computed(() => {
8181
return props.items;
@@ -99,6 +99,16 @@ const boundProps = computed(() => {
9999
};
100100
});
101101
102+
// -------------------------------------------------- Slot content check //
103+
onMounted(() => {
104+
const slotContentCheck = document.querySelector(`[data-id="vdt-top-id-${props.level}"]`) as HTMLElement;
105+
106+
// ? If slot does not have content, hide the column to avoid unnecessary space //
107+
if (slotContentCheck?.children.length === 0) {
108+
showTopContent.value = false;
109+
}
110+
});
111+
102112
103113
// -------------------------------------------------- Callbacks //
104114
function selectAllCallback(val: boolean) {

0 commit comments

Comments
 (0)