From bbadc4f42d6568295ab7789ee8a2d13529ac5574 Mon Sep 17 00:00:00 2001 From: Pier-Luc Gendreau Date: Mon, 10 Oct 2022 11:32:47 -0400 Subject: [PATCH] Only unmount hidden inactive tabs (#390) --- .changeset/short-turkeys-matter.md | 5 +++++ packages/lib/src/TabPanel.tsx | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/short-turkeys-matter.md diff --git a/.changeset/short-turkeys-matter.md b/.changeset/short-turkeys-matter.md new file mode 100644 index 0000000..2abd4db --- /dev/null +++ b/.changeset/short-turkeys-matter.md @@ -0,0 +1,5 @@ +--- +"react-headless-tabs": patch +--- + +Only unmount hidden inactive tabs diff --git a/packages/lib/src/TabPanel.tsx b/packages/lib/src/TabPanel.tsx index 3d95563..99b26f0 100644 --- a/packages/lib/src/TabPanel.tsx +++ b/packages/lib/src/TabPanel.tsx @@ -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 () => {