diff --git a/components/src/preact/components/tabs.tsx b/components/src/preact/components/tabs.tsx index c7b01e1f..25867ec8 100644 --- a/components/src/preact/components/tabs.tsx +++ b/components/src/preact/components/tabs.tsx @@ -1,5 +1,5 @@ -import { Fragment, type FunctionComponent } from 'preact'; -import { useEffect, useRef, useState } from 'preact/hooks'; +import { type FunctionComponent } from 'preact'; +import { useState } from 'preact/hooks'; import { type JSXInternal } from 'preact/src/jsx'; type Tab = { @@ -14,43 +14,24 @@ interface ComponentTabsProps { const Tabs: FunctionComponent = ({ tabs, toolbar }) => { const [activeTab, setActiveTab] = useState(tabs[0]?.title); - const [heightOfTabs, setHeightOfTabs] = useState('3rem'); - const tabRef = useRef(null); - - const updateHeightOfTabs = () => { - if (tabRef.current) { - const heightOfTabs = tabRef.current.getBoundingClientRect().height; - setHeightOfTabs(`${heightOfTabs}px`); - } - }; - - useEffect(() => { - updateHeightOfTabs(); - - window.addEventListener('resize', updateHeightOfTabs); - return () => { - window.removeEventListener('resize', updateHeightOfTabs); - }; - }, []); const tabElements = (
{tabs.map((tab) => { return ( - - - + ); })}
@@ -59,17 +40,16 @@ const Tabs: FunctionComponent = ({ tabs, toolbar }) => { const toolbarElement = typeof toolbar === 'function' ? toolbar(activeTab) : toolbar; return ( -
-
+
+
{tabElements} {toolbar &&
{toolbarElement}
}
{tabs.map((tab) => ( -