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

TabView does not remove all dynamic tabs programmatically #2608

Closed
ghost opened this issue Jan 25, 2022 · 7 comments
Closed

TabView does not remove all dynamic tabs programmatically #2608

ghost opened this issue Jan 25, 2022 · 7 comments
Assignees
Labels
Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted

Comments

@ghost
Copy link

ghost commented Jan 25, 2022

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Codesandbox Case (Bug Reports)
https://codesandbox.io/s/rough-waterfall-6tnbv?file=/src/demo/TabViewDemo.js

Current behavior
When closing tabs that is not an active tab until the last tab (which is active) and then we try to close the active tab, the state in which we are setting those dynamic tabs to render is not getting empty. It always has one last tab in it. This issue was not there in 7.1.0

Expected behavior
When closing tabs and removing them from their state value programmatically, expect the state variable array to become empty after removing the last one.

Minimal reproduction of the problem with instructions
Have provided the code in sandbox.

To reproduce the issue: Keep Tab 3 active, then close Tab 2, then Tab 1. Finally close Tab 1. In the console logs, I have given length of the array from which I am rendering the tabs. It remains as 1 instead of empty. If we close the tabs in order, then it works fine.
I've downgraded to 7.1.0 locally and couldn't find this issue.
I've also got another major issue but I couldn't reproduce it in the sandbox but that too disappears in 7.1.0. Issue is that if I try to close an inactive tab, then 2 tabs are disappearing from the screen although the tab state variable shows 2 tab objects in the array.

  • React version:
    17.0.2

  • PrimeReact version:
    7.2.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome

@melloware
Copy link
Member

I wonder if its related to this fix: #2573

@ghost
Copy link
Author

ghost commented Jan 27, 2022

I think so too :(

@yigitfindikli yigitfindikli added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Feb 10, 2022
@yigitfindikli yigitfindikli self-assigned this Feb 10, 2022
@yigitfindikli yigitfindikli added this to the 7.2.1 milestone Feb 10, 2022
@yigitfindikli yigitfindikli modified the milestones: 7.2.1, Future Feb 17, 2022
@melloware
Copy link
Member

I fixed your code sandbox reproducer to work: https://codesandbox.io/s/boring-danilo-26v443?file=/src/demo/TabViewDemo.js

So i don't know what the behavior was before but now once a tab is created its assigned an index. That index never changes and it looks like your code was expecting the indexes to reshuffle after each Tab removal?

@melloware melloware assigned melloware and unassigned mcandu Apr 22, 2022
@melloware melloware added Resolution: Needs More Information More information about the issue is needed to find a correct solution and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Apr 22, 2022
@melloware melloware modified the milestones: Future, 8.0.1 Apr 22, 2022
@melloware melloware added the Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team label Apr 22, 2022
@melloware melloware changed the title TabView does not remove all dynamic tabs programmatically - issue not there in 7.1.0 TabView does not remove all dynamic tabs programmatically Apr 22, 2022
@melloware melloware removed this from the 8.0.1 milestone Apr 22, 2022
@ssshammi
Copy link

I am facing the same issue if the tabs are dynamically added to the dom and then click to close then it leaves the tab inactive but does not delete it.

@melloware
Copy link
Member

@ssshammi can you update my code sandbox to show the issue: https://codesandbox.io/s/adoring-tesla-s88jxf

@djapal
Copy link

djapal commented Jul 4, 2023

i dont know if I have sth wrong in my code but when i try to delete the tabs and update the tabpanels (which are dynamically generated), 2 elements are deleted.

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

@melloware
Copy link
Member

Duplicate of: #2842

@melloware melloware added Resolution: Duplicate Issue has already been reported or a pull request related to same issue has already been submitted and removed Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team Resolution: Needs More Information More information about the issue is needed to find a correct solution labels Jul 4, 2023
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.

5 participants