Skip to content

Commit 47ed687

Browse files
committed
Fix slow tab switching by keeping all tab components mounted
1 parent 7d74c98 commit 47ed687

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

apps/twig/src/renderer/features/panels/components/TabbedPanel.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ export const TabbedPanel: React.FC<TabbedPanelProps> = ({
7979
rightContent,
8080
emptyState,
8181
}) => {
82-
const activeTab = content.tabs.find((tab) => tab.id === content.activeTabId);
83-
8482
const handleSplitClick = async () => {
8583
const result = await trpcVanilla.contextMenu.showSplitContextMenu.mutate();
8684
if (result.direction) {
@@ -246,8 +244,19 @@ export const TabbedPanel: React.FC<TabbedPanelProps> = ({
246244
position="relative"
247245
onClick={() => onPanelFocus?.(panelId)}
248246
>
249-
{activeTab ? (
250-
activeTab.component
247+
{content.tabs.length > 0 ? (
248+
content.tabs.map((tab) => (
249+
<div
250+
key={tab.id}
251+
style={
252+
tab.id === content.activeTabId
253+
? { height: "100%" }
254+
: { display: "none" }
255+
}
256+
>
257+
{tab.component}
258+
</div>
259+
))
251260
) : emptyState ? (
252261
emptyState
253262
) : (

0 commit comments

Comments
 (0)