Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Tabs destroyInactiveTabPanel unmounts inactive tabs' content #3159

Closed
n-d-r-d-g opened this issue Jun 1, 2024 · 3 comments · Fixed by #3164
Closed

[BUG] - Tabs destroyInactiveTabPanel unmounts inactive tabs' content #3159

n-d-r-d-g opened this issue Jun 1, 2024 · 3 comments · Fixed by #3164
Assignees
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working

Comments

@n-d-r-d-g
Copy link

NextUI Version

2.4.1

Describe the bug

Hi,

I currently have 2 tabs and a Formik component in each. I need the form data to not be cleared when switching between the tabs. When I set destroyInactiveTabPanel={false}, the inactive tab's Formik instance gets unmounted as soon as I switch to the other tab.

I investigated this issue. I set a unique id on each content (simplified example).

<Tabs destroyInactiveTabPanel={false}>
  <Tab key="tab1">
    <p id="first">First tab content</p>
  </Tab>
  <Tab key="tab2">
    <input id="tab2" />
  </Tab>
</Tabs>

In DevTools, I can see 2 <div>s, one for each tab. The inactive tab has a display: none; but the content inside both tabs' <div>s are the same, i.e. the active tab's content. When I switch to the other tab, then the same happens. The inactive tab's content is unmounted. I tried setting unique keys on each tab and their content, but no luck.

Is there anything I'm doing wrong?

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

N/A

Expected behavior

I would expect all tabs to be mounted at all times when destroyInactiveTabPanel={false}.

Screenshots or Videos

No response

Operating System Version

Browser

Chrome

Copy link

linear bot commented Jun 1, 2024

@wingkwong
Copy link
Member

can you share a stackblitz project with Tabs + Formik for us to investigate?

@n-d-r-d-g
Copy link
Author

n-d-r-d-g commented Jun 1, 2024

@wingkwong I'm not able to get destroyInactiveTabPanel={false} working in this example. I didn't add Formik yet. Maybe you can look into it without Formik first?

In the Stackblitz example, type something in the input on the first tab. Switch to the second tab, then back to the first one. The text disappears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 Scope : Components Related to the components 🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants