Skip to content

Commit bbadc4f

Browse files
authored
Only unmount hidden inactive tabs (#390)
1 parent 3c2ccda commit bbadc4f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/short-turkeys-matter.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-headless-tabs": patch
3+
---
4+
5+
Only unmount hidden inactive tabs

packages/lib/src/TabPanel.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ export function TabPanel({
4444
}
4545

4646
if (typeof unmount === "number") {
47-
unmountRef.current = wait(() => setShouldRender(false), unmount * 1000);
47+
unmountRef.current = wait(
48+
() => setShouldRender(!props.hidden),
49+
unmount * 1000
50+
);
4851
}
4952

5053
return () => {

0 commit comments

Comments
 (0)