ui icon indicating copy to clipboard operation
ui copied to clipboard

Shadcn deletes Tab Content

Open TerraCraftere3 opened this issue 1 year ago • 1 comments

Hey, i am working on a little project in next.js and wanted to use shadcn for my ui. I wanted to have two editor tabs and used the tab element for that. The problem is: If i select another tab and then switch back to the other tab it resets the code because shadcn deletes the inactive element

TerraCraftere3 avatar Jan 29 '24 13:01 TerraCraftere3

You can use the forceMount attribute on TabContent.

And don’t forget to set hidden

image

TinsFox avatar Jan 31 '24 02:01 TinsFox

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.

shadcn avatar Feb 22 '24 23:02 shadcn

I had the same issue, if you don't have an array, you can do:

<TabsContent
  value="tab-1"
  forceMount
  className="data-[state=inactive]:hidden"
 >
          ...
</TabsContent>
<TabsContent
  value="tab-2"
  forceMount
  className="data-[state=inactive]:hidden"
 >
          ...
</TabsContent>

EverStarck avatar Aug 12 '24 00:08 EverStarck