primefaces / primefaces/primereact

AccordionTab: is being removed from DOM on closing Tab

Open
#6,543 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Discussion
Dominant language
CSS
Stars
8.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the AccordionTab behavior shown in the linked StackBlitz reproducer and trace how closing a tab affects its DOM content. Compare the current behavior with the reported PrimeVue and PrimeNG behavior. Done means closed tabs retain their form fields so reopening preserves them and validation can cover fields across tabs.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript, vite
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.