fix(tabs): remove the tab from its parent collection on dispose - #319
Merged
Conversation
damyanpetev
force-pushed
the
dpetev/tabs-collection-fix
branch
from
August 7, 2026 06:59
75908cc to
e5cab82
Compare
damyanpetev
force-pushed
the
dpetev/tabs-collection-fix
branch
from
August 7, 2026 10:45
e5cab82 to
a03a31e
Compare
damyanpetev
commented
Aug 7, 2026
20 tasks
IgbTab.Dispose called ContentTabsCollection.Add(this) -- the same call OnInitializedAsync makes -- so disposing a tab appended it to the collection a second time instead of taking it out. ContentTabsCollection is the query side of the CollectionAdapter built in the IgbTabs constructor, so SyncItems then walked a query containing the instance twice and inserted it into ActualTabsCollection twice. With two tabs rendered, dropping one grew the serialized collection from 2 to 3 and dropping both grew it to 4, leaving disposed tabs in the payload forever. The other five parent/child families (ExpansionPanel, DropdownItem, SelectItem, Tile, TreeItem) all call ContentItems.Remove(this) here; IgbTab is the only one whose registration lives in a generated file rather than a hand-written partial. Adds three tests: registration on initialize, one child disposed, and all children disposed. The two regression tests were confirmed failing against the bug before the fix. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Damyan Petev <damyanpetev@users.noreply.github.com>
damyanpetev
force-pushed
the
dpetev/tabs-collection-fix
branch
from
August 7, 2026 15:33
8c0f3b3 to
52242bf
Compare
damyanpetev
marked this pull request as ready for review
August 7, 2026 15:33
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a lifecycle bug in the Ignite UI for Blazor IgbTab component where disposing a tab incorrectly added it back into its parent IgbTabs collection, causing stale/duplicated tab references to persist after re-renders.
Changes:
- Corrected
IgbTab.Dispose()to remove the tab fromIgbTabs.ContentTabsCollectioninstead of adding it. - Added unit tests validating tab registration on initialization and proper collection updates when one/all child tabs are disposed via re-render.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/components/Blazor/Tab.cs |
Fixes teardown logic to remove disposed tabs from the parent tabs collection. |
tests/IgniteUI.Blazor.Tests/TabsTests.cs |
Adds regression tests covering child tab registration and removal from ActualTabsCollection on disposal. |
dkamburov
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IgbTab.Dispose()calledContentTabsCollection.Add(this)— the same callOnInitializedAsyncmakes directly above it:The fix:
Add→Remove. This is what the other five parent/child handling have always done —IgbExpansionPanel,IgbDropdownItem,IgbSelectItem,IgbTileandIgbTreeItemall callContentItems.Remove(this)inDispose.Adds three tests: registration on initialize, one child disposed, and all children disposed. The two regression tests were confirmed failing against the bug before the fix.
Type of Change (check all that apply):
How Has This Been Tested?
Checklist:
README.MDCHANGELOG.MDupdates for newly added functionality