Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/Components/src/Sections/SectionContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Task IComponent.SetParametersAsync(ParameterView parameters)
}

_registry.AddProvider(identifier, this, IsDefaultContent);
_registeredIdentifier = SectionId;
_registeredIdentifier = identifier;
_registeredIsDefaultContent = IsDefaultContent;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Components/src/Sections/SectionOutlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Task IComponent.SetParametersAsync(ParameterView parameters)
}

_registry.Subscribe(identifier, this);
_subscribedIdentifier = SectionId;
_subscribedIdentifier = identifier;
}

RenderContent();
Expand Down
27 changes: 27 additions & 0 deletions src/Components/test/E2ETest/Tests/SectionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,33 @@ public void RenderSectionContentWithSectionName_MatchingSectionOutletRendersCont
Browser.Exists(By.Id("test6"));
}

[Fact]
public void SectionContentWithSectionNameGetsDisposed_OldSectionOutletNoLongerRendersContent()
{
_appElement.FindElement(By.Id("section-content-with-name")).Click();

Browser.Exists(By.Id("test6"));

_appElement.FindElement(By.Id("section-content-with-name-dispose")).Click();

Browser.DoesNotExist(By.Id("test6"));
}

[Fact]
public void SectionOutletWithSectionNameGetsDisposed_ContentDissapears()
{
// Render Counter and change its id so the content is rendered in second SectionOutlet
_appElement.FindElement(By.Id("counter-render-section-content")).Click();

_appElement.FindElement(By.Id("counter-change-section-content-id")).Click();

Browser.Exists(By.Id("counter"));

_appElement.FindElement(By.Id("second-section-outlet-dispose")).Click();

Browser.DoesNotExist(By.Id("counter"));
}

[Fact]
public void RenderTwoSectionContentsWithSameSectionId_LastRenderedOverridesSectionOutletContent()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,27 @@

<p>Text between two section outlets</p>

<SectionOutlet SectionName="@SecondSectionName" />
@if (SecondSectionOutletExists)
{
<SectionOutlet SectionName="@SecondSectionName" />
}

<p>Text between two section outlets</p>

<SectionOutlet SectionId="ThirdSectionName" />


<button id="section-outlet-dispose"
@onclick="@(() => FirstSectionOutletExists = false)">
Dispose first SectionOutlet
</button>

<br/>

<button id="second-section-outlet-dispose"
@onclick="@(() => SecondSectionOutletExists = false)">
Dispose second SectionOutlet
</button>

@if (SectionOutletWithSameSectionIdExists)
{
<SectionOutlet SectionId="FirstSectionId" />
Expand Down Expand Up @@ -114,6 +123,11 @@
Change SectionContent SectionName
</button><br />

<button id="section-content-with-name-dispose"
@onclick="@(() => SectionContentWithSectionNameExists = false)">
Dispose SectionContent SectionName
</button><br />

<Counter
SectionContentExists="CounterSectionContentExists"
SectionId="CounterSectionContentId">
Expand Down Expand Up @@ -164,6 +178,7 @@

@code {
private bool FirstSectionOutletExists = true;
private bool SecondSectionOutletExists = true;
private bool SectionOutletWithSameSectionIdExists = false;
private bool SectionOutletWithSameSectionNameExists = false;
private bool SectionOutletWithEqualSectionNameToSectionIdExist = false;
Expand Down