primereact icon indicating copy to clipboard operation
primereact copied to clipboard

AccordionTab: is being removed from DOM on closing Tab

Open kingmauri opened this issue 1 year ago • 3 comments

Describe the bug

When using the accordion component, the tab is removed from the DOM once it is closed. This could be problematic, for example, when forms and input fields are used as content, as the content of the input field is deleted when closing and reopening. Of course, one could store the content of the field in a useState (as in the example), but the problem with form validation persists because only the fields of the current tab are validated, not all of them. The entire form cannot be validated if there are form fields in the different accordion tabs.

I compared the component with other libraries like PrimeVue and PrimeNG, where the content of the DOM is NOT deleted. Is there a simple way to prevent the accordion tab from being removed from the DOM when the tab is closed?

Reproducer

https://stackblitz.com/edit/rdg6zx-hjxnyv?file=src%2FApp.jsx

PrimeReact version

10.6.4

React version

17.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

kingmauri avatar May 02 '24 07:05 kingmauri

I completely agree, this makes the accordion non usable in most cases. The choice should be given to the user, if possible. Or by default, the content should be hidden but not removed from the DOM.

jerlam06 avatar Jun 13 '24 12:06 jerlam06

I disagree. See my comment in @jerlam06 issue #6755

Even at react.dev docs they do it the way PrimeReact is doing it.

sja-cslab avatar Jun 19 '24 08:06 sja-cslab

I tend to agree with @sja-cslab here. Removing something from the DOM is always the preferred approach as their is less in the DOM tree not being used.

melloware avatar Jun 19 '24 11:06 melloware