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

TabPanel: dynamic add/close weird behavior #4606

Closed
djapal opened this issue Jul 4, 2023 · 3 comments
Closed

TabPanel: dynamic add/close weird behavior #4606

djapal opened this issue Jul 4, 2023 · 3 comments
Labels
Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted

Comments

@djapal
Copy link

djapal commented Jul 4, 2023

Describe the bug

Unless there is something I'm missing here, I want to have a static tab panel (or a button) with a list of items and when i click then the item should be displayed on a new tab.
This is OK but when i want to close the tab, then weird things happen.

Here is a sample

https://codesandbox.io/s/eloquent-roentgen-d9ss7y?file=/src/demo/TabViewDemo.js

When i click an item to be closed, then 2 tabs are closed.
If i remove the line which updates the list of tabs, it works fine, but this means that

{tabPanels.map((tab) => { return ( <TabPanel closable header={tab.header} key={tab.id}> {tab.body} </TabPanel> ); })}

this is ignored and only applied at first render.
How can we update the component based on the list that we provide in map function? Does tab panel depend on another internal list?

Reproducer

https://codesandbox.io/s/eloquent-roentgen-d9ss7y?file=/src/demo/TabViewDemo.js

PrimeReact version

9.6.0

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Firefox 114

Steps to reproduce the behavior

Just click the Tab 1 to be removed. Tab 2 is also removed.

Expected behavior

Only 1 tab at a time should be closed. Removing line
setTabPanels(tabPanels.filter((p, i) => i !== e.index - 1)); makes things work but the point is to depend on the dynamically changed list of tabs.

@djapal djapal added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jul 4, 2023
@melloware
Copy link
Member

Duplicate of: #2842

There is an open PR to fix it which has not been reviewed by PrimeTek.

@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2023
@melloware melloware added Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jul 4, 2023
@djapal
Copy link
Author

djapal commented Jul 4, 2023

Duplicate of: #2842

There is an open PR to fix it which has not been reviewed by PrimeTek.

sorry i saw another related issue and thought this was a different one. thank you

@melloware
Copy link
Member

I linked that PR to this ticket as well so we know in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants