export const getMaxZIndex = () => Math.max( ...Array.from(document.querySelectorAll('body *'), (el) => parseFloat(window.getComputedStyle(el).zIndex), ).filter((zIndex) => !Number.isNaN(zIndex)), 0, ); export function handleElementPosition(id: string) { let element: HTMLElement | null = null; onMounted(() => { element = document.getElementById(id); if (element) { element.style.position = 'fixed'; element.style.zIndex = (getMaxZIndex() + 1).toString(); } }); onBeforeUnmount(() => { if (element && element.parentNode) { element.parentNode.removeChild(element); } }); }