Skip to content

fix(tabs): remove the tab from its parent collection on dispose - #319

Merged
dkamburov merged 2 commits into
masterfrom
dpetev/tabs-collection-fix
Aug 10, 2026
Merged

fix(tabs): remove the tab from its parent collection on dispose#319
dkamburov merged 2 commits into
masterfrom
dpetev/tabs-collection-fix

Conversation

@damyanpetev

Copy link
Copy Markdown
Member

IgbTab.Dispose() called ContentTabsCollection.Add(this) — the same call OnInitializedAsync makes directly above it:

public void Dispose()
{
    if (TabsParent != null)
    {
        var sv = (IgbTabs)TabsParent;
        sv.ContentTabsCollection.Add(this);   // Add, on teardown
    }
}

The fix: AddRemove. This is what the other five parent/child handling have always done — IgbExpansionPanel, IgbDropdownItem, IgbSelectItem, IgbTile and IgbTreeItem all call ContentItems.Remove(this) in Dispose.

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):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Checklist:

  • [ x] All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code
  • This PR includes API docs for newly added methods/properties
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

@damyanpetev damyanpetev added the 🐛 bug Something isn't working label Aug 6, 2026
@damyanpetev
damyanpetev force-pushed the dpetev/tabs-collection-fix branch from 75908cc to e5cab82 Compare August 7, 2026 06:59
Base automatically changed from dpetev/dead-code-cleanup to master August 7, 2026 10:45
@damyanpetev
damyanpetev force-pushed the dpetev/tabs-collection-fix branch from e5cab82 to a03a31e Compare August 7, 2026 10:45
Comment thread tests/IgniteUI.Blazor.Tests/TabsTests.cs Outdated
damyanpetev and others added 2 commits August 7, 2026 18:33
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
damyanpetev force-pushed the dpetev/tabs-collection-fix branch from 8c0f3b3 to 52242bf Compare August 7, 2026 15:33
@damyanpetev
damyanpetev marked this pull request as ready for review August 7, 2026 15:33
Copilot AI review requested due to automatic review settings August 7, 2026 15:33
@damyanpetev damyanpetev added the squash-merge Merge PR with "Squash and Merge" option label Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from IgbTabs.ContentTabsCollection instead 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
dkamburov merged commit d20df73 into master Aug 10, 2026
8 checks passed
@dkamburov
dkamburov deleted the dpetev/tabs-collection-fix branch August 10, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working squash-merge Merge PR with "Squash and Merge" option

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants