-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
src/OrchardCore/OrchardCore.DisplayManagement/Extensions/IHtmlContentExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.DisplayManagement/Extensions/IHtmlContentExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.DisplayManagement/Extensions/IHtmlContentExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.DisplayManagement/Extensions/IHtmlContentExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.DisplayManagement/Extensions/IHtmlContentExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.DisplayManagement/Title/PageTitleBuilder.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.DisplayManagement/Extensions/HtmlContentExtensions.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.DisplayManagement/Title/PageTitleBuilder.cs
Outdated
Show resolved
Hide resolved
Can you add a unit tests for this? |
I try....pls be patient with me :D |
Test added... I could ask to you to give me a feeback about a discussion that I have open a month ago? I don't link it here because is something completely off topic. Thank you PS. Is something that seem simple... |
test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs
Outdated
Show resolved
Hide resolved
test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs
Outdated
Show resolved
Hide resolved
test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs
Outdated
Show resolved
Hide resolved
Thanks again @PiemP |
There's no fail in the build now |
Make sure to not break the use case where someone wants to reset the page title by intentionally passing a string empty to RenderTitleSegments. |
What do you intend with reset the page title? I have look at RazorPage.cs and Page.cs in the first case passing the empty string cause the print of the Would you like that I make |
See #14284 (comment) |
src/OrchardCore/OrchardCore.DisplayManagement/Title/PageTitleBuilder.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore/OrchardCore.DisplayManagement/Extensions/HtmlContentExtensions.cs
Outdated
Show resolved
Hide resolved
test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs
Outdated
Show resolved
Hide resolved
test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs
Outdated
Show resolved
Hide resolved
converted to draft see #14284 (comment) |
@PiemP So based on our discussion, see #14284 (comment), here my suggestion.
|
Have I to remove |
Yes for now you can remove the extension and only use the mentioned changes. Otherwise would need to be optimized, for example by using a |
For the tests purpose I prefer to maintain it if it's possible. Why exists 2 |
Maybe would need to be named But not sure it's good to encourage people to use it. If you need it in the tests, why not just using a dedicated private method in the test class. |
fix: removed HtmlContentExtension, avoid unwant use of it fix: changed tests code to use a private version of extension removed
Can we replace this code: by if (_titleParts.Count == 0)
{
return HtmlString.Empty;
}
// _titleParts.Count * 2 because we add a separator for each entry
var htmlContentBuilder = new HtmlContentBuilder(_titleParts.Count * 2); |
fix: init HtmlContentBuilder with a size
test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs
Outdated
Show resolved
Hide resolved
test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs
Outdated
Show resolved
Hide resolved
😅 ... maybe I have understand the changes requested by @hishamco ... sorry guys I'm pretty new to the things related to tests ... hope to have done all right. |
I might revise this one |
Great, thank you! |
* fix: title empty if AddSegment is not called * style: renamed extension file and class * style: sort usign, remove extra line * test: added tests for PageTitleBuilder * test: removed empty lines, String.Empty * style: added const in test, line and string.Empty * fix: use different check for empty title fix: removed HtmlContentExtension, avoid unwant use of it fix: changed tests code to use a private version of extension removed * fix: moved HtmlContentBuilder in a best position fix: init HtmlContentBuilder with a size * fix: comment, using var * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs --------- Co-authored-by: Hisham Bin Ateya <[email protected]>
* fix: title empty if AddSegment is not called * style: renamed extension file and class * style: sort usign, remove extra line * test: added tests for PageTitleBuilder * test: removed empty lines, String.Empty * style: added const in test, line and string.Empty * fix: use different check for empty title fix: removed HtmlContentExtension, avoid unwant use of it fix: changed tests code to use a private version of extension removed * fix: moved HtmlContentBuilder in a best position fix: init HtmlContentBuilder with a size * fix: comment, using var * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs --------- Co-authored-by: Hisham Bin Ateya <[email protected]>
* fix: title empty if AddSegment is not called * style: renamed extension file and class * style: sort usign, remove extra line * test: added tests for PageTitleBuilder * test: removed empty lines, String.Empty * style: added const in test, line and string.Empty * fix: use different check for empty title fix: removed HtmlContentExtension, avoid unwant use of it fix: changed tests code to use a private version of extension removed * fix: moved HtmlContentBuilder in a best position fix: init HtmlContentBuilder with a size * fix: comment, using var * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs * Update test/OrchardCore.Tests/DisplayManagement/Title/PageTitleBuilderTests.cs --------- Co-authored-by: Hisham Bin Ateya <[email protected]>
Fixes #14284