From dae42a4657d1345777160a34d24671e0d37c03ba Mon Sep 17 00:00:00 2001 From: Geriano Date: Mon, 18 Jul 2022 18:47:17 +0700 Subject: [PATCH] fix bug floating border rounded th element --- resources/js/Components/DataTable/Builder.vue | 37 +++++++++++++++++-- resources/js/Components/DataTable/Th.vue | 28 +------------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/resources/js/Components/DataTable/Builder.vue b/resources/js/Components/DataTable/Builder.vue index 77de201..ea2e2e1 100644 --- a/resources/js/Components/DataTable/Builder.vue +++ b/resources/js/Components/DataTable/Builder.vue @@ -4,6 +4,7 @@ import axios from 'axios' import Swal from 'sweetalert2' import { getCurrentInstance, onMounted, ref } from 'vue' +const self = getCurrentInstance() const { url, sticky } = defineProps({ url: String, sticky: { @@ -45,7 +46,37 @@ const fetch = async u => { } } +const createFloatingTh = () => { + const { thead, tfoot, tbody } = self.refs + + if (thead) { + let ths = thead.querySelectorAll('th') + ths.forEach((th, i) => { + const floating = document.createElement('div') + floating.className = 'absolute top-0 left-0 w-full h-full border border-1 border-inherit' + i === 0 && floating.classList.add('rounded-tl-md') + i + 1 === ths.length && floating.classList.add('rounded-tr-md') + + th.append(floating) + }) + } + + if (tfoot) { + let ths = tfoot.querySelectorAll('th') + ths.forEach((th, i) => { + const floating = document.createElement('div') + floating.className = 'absolute top-0 left-0 w-full h-full border border-1 border-inherit' + i === 0 && floating.classList.add('rounded-bl-md') + i + 1 === ths.length && floating.classList.add('rounded-br-md') + + th.append(floating) + }) + } +} + onMounted(fetch) + +onMounted(() => config.sticky && createFloatingTh()) \ No newline at end of file