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

fix: title empty if AddSegment is not called #14295

Merged
merged 14 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Encodings.Web;
PiemP marked this conversation as resolved.
Show resolved Hide resolved
using Microsoft.AspNetCore.Html;

PiemP marked this conversation as resolved.
Show resolved Hide resolved

namespace OrchardCore.DisplayManagement.Extensions;

public static class IHtmlContentExtensions
PiemP marked this conversation as resolved.
Show resolved Hide resolved
{
public static string GetString(this IHtmlContent content)
{
using var writer = new System.IO.StringWriter();
PiemP marked this conversation as resolved.
Show resolved Hide resolved
content.WriteTo(writer, HtmlEncoder.Default);
return writer.ToString();
PiemP marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Html;
using OrchardCore.DisplayManagement.Zones;
using OrchardCore.DisplayManagement.Extensions;

namespace OrchardCore.DisplayManagement.Title
{
Expand Down Expand Up @@ -48,7 +49,7 @@ public IHtmlContent GenerateTitle(IHtmlContent separator)
return _fixedTitle;
}

if (_title != null)
if (_title != null && System.String.Empty != _title.GetString())
PiemP marked this conversation as resolved.
Show resolved Hide resolved
{
return _title;
}
Expand Down Expand Up @@ -82,6 +83,7 @@ public IHtmlContent GenerateTitle(IHtmlContent separator)
public void Clear()
{
_fixedTitle = null;
_title = null;
_titleParts.Clear();
}
}
Expand Down