-
Notifications
You must be signed in to change notification settings - Fork 1k
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
TabView: Dynamically created TabPanels and onTabClose closes more than one Tab #2842
Comments
Excellent reproducer. Definitely a bug |
The ".splice()" method refers the same array, so it might be more suitable to use the "filter" method as shown below:
|
My reproducer didn't exactly do, what my react project does... In my project I'm sending a request to a server and the server tells me to remove this component. The server can remove a lot of components that's why I have an extra hook for that.
Then I'm experiencing the same issues as before. Btw. in my app I'm not checking with
|
|
And |
The issue maybe is, that PrimeReact is closing a Tab when clicking the 'X' and I'm also removing a Tab. So 2 Tabs are removed? Maybe there could be a mode for the TabView where PrimeReact doesn't close Tabs and lets the User handle the closing? |
@maximilianweidenauer there's this PR that adds |
This is fixed by: #5229 |
Describe the bug
I have a TabView with dynamically created TabPanels, some are closable and some are disabled. When closing one of them, an additional TabPanel gets closed or isn't visible anymore. In my example there are 5 Tabs when closing the third, the forth won't be displayed aswell. (In my demo, the activeIndex stays 0 because in my app it shouldn't switch on close, when it isn't the currently selected one)
Reproducer
https://codesandbox.io/s/misty-worker-1lu9yy?file=/src/demo/TabViewDemo.js
PrimeReact version
7.2.1 (tested with 8.0.1 too)
React version
17.x
Language
TypeScript
Build / Runtime
Create React App (CRA)
Browser(s)
Chrome
Steps to reproduce the behavior
Expected behavior
When I close the third Tab, only the third Tab gets removed.
The text was updated successfully, but these errors were encountered: