-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix root '<PageTitle>' not working when a default, static '<title>' is provided #35982
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
Conversation
| [Parameter] public string Name { get; set; } = default!; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets whether this component should provide the default content for the target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I mind this change - but what happens if we remove this property and treat it as it it were always true - given that there's only one thing that provides it today?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SectionContent is also used in PageTitle:
| builder.OpenComponent<SectionContent>(0); |
It doesn't specify IsDefaultContent because it's false for every case other than the default title, which is rendered by HeadOutlet.
Am I understanding the suggestion correctly?
|
/backport to release/6.0 |
|
Hi @MackinnonBuck. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
|
Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1195087954 |
Fix root
<PageTitle>not working when a default, static<title>is providedThere was an issue in which the root
<PageTitle>, if rendered just after the application started, would not change the title of the page if a static<title>was provided inindex.html. This PR fixes the issue.PR Description
The problem arose because
HeadOutletwouldn't render the default title until it was determined from the statically-rendered title. This gave other<PageTitle>components the opportunity to render first, incorrectly serving as the default page title. When the true default title finally rendered, it took priority over the developer-provided<PageTitle>(which was rendered first), making it appear to have no effect.I've added a new
SectionContentparameter,IsDefaultContent. Whentrue, the registered section content will take lower priority than all other existing content. This allows theHeadOutletto ensure its ownSectionContentfor the default title will have the lowest priority.An alternative I considered was to always render the
SectionContentfor the default title, but only render the<title>element when the default title is actually determined. This sometimes works, but it breaks in cases like prerendering because<PageTitle>elements in the "app" root component still get rendered first.Fixes #35973