Skip to content

Commit

Permalink
Only unmount hidden inactive tabs (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zertz committed Oct 10, 2022
1 parent 3c2ccda commit bbadc4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/short-turkeys-matter.md
@@ -0,0 +1,5 @@
---
"react-headless-tabs": patch
---

Only unmount hidden inactive tabs
5 changes: 4 additions & 1 deletion packages/lib/src/TabPanel.tsx
Expand Up @@ -44,7 +44,10 @@ export function TabPanel({
}

if (typeof unmount === "number") {
unmountRef.current = wait(() => setShouldRender(false), unmount * 1000);
unmountRef.current = wait(
() => setShouldRender(!props.hidden),
unmount * 1000
);
}

return () => {
Expand Down

1 comment on commit bbadc4f

@vercel
Copy link

@vercel vercel bot commented on bbadc4f Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.