question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Svg `title` and `text` tags conflict with Blazor `title` / `text` tags

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I’m in the process of migrating our Blazor Server app from .net 5 to .net 6 when I noticed a little quirk with the page title. On pages where I haven’t used the <PageTitle /> component, it would show the word “Menu”.

After some investigation, it appears that Blazor is picking up the <title>Menu</title> element from an svg I have in my site navigation (which is at the beginning of every page)!

Expected Behavior

Which was a little surprising! I thought that the page title would only be affected by the head/title element or the PageTitle component. At the very least it should ignore the title element of an svg.

Steps To Reproduce

  1. Create a new Blazor Server app - choose .net 6 (and default options)
  2. Remove the PageTitle component from MainLayout.razor and Index.razor
  3. Add the following svg - in either MainLayout.razor or Index.razor
<svg height="1em" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><title>Menu</title><path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z" /></svg>

Exceptions (if any)

No response

.NET Version

6.0.300-preview.22154.4

Anything else?

I’m using Visual Studio 2022 17.1.3 I also have Visual Studio 2022 17.2.0 Preview 2.1 - which I think explains the .net version (above)

Output from dotnet --info:

.NET SDK (reflecting any global.json):
 Version:   6.0.300-preview.22154.4
 Commit:    1eb22793b6

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.300-preview.22154.4\

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  3.1.417 [C:\Program Files\dotnet\sdk]
  5.0.104 [C:\Program Files\dotnet\sdk]
  5.0.212 [C:\Program Files\dotnet\sdk]
  5.0.406 [C:\Program Files\dotnet\sdk]
  6.0.201 [C:\Program Files\dotnet\sdk]
  6.0.300-preview.22154.4 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mitkinscommented, Apr 8, 2022

I tried the first option, adding the <text> element didn’t help. When I try the second option, I get a red squiggly line on the :

image

This is the error:

RZ1005 “:” is not valid at the start of a code block. Only identifiers, keywords, comments, “(” and “{” are valid

0reactions
chrdlxcommented, Aug 17, 2022

I can reproduce this issue, I had to remove the

<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered"/>

tag from the default _Layout.cshtml template to avoid the bug. It seems that component erases <title> tags from the whole html… if I make a change in a component and trigger a hot reload, the <title> tags appear again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Svg title and text tags conflict with Blazor title / text tags #7264
After some investigation, it appears that Blazor is picking up the <title>Menu</title> element from an svg I have in my site navigation (which ......
Read more >
How to add SVG <text> in Blazor/razor file
How do I write an SVG <text> element in razor syntax? I don't want to revert to C# and HtmlString etc. Update: Missing...
Read more >
<title> — the SVG accessible name element - MDN Web Docs
The element provides an accessible, short-text description of any SVG container element or graphics element.
Read more >
How to display image in blazor. svg file in a text editor ...
Provide a Project Name and confirm that the Location is correct. ... 1 Answer. svg), are supported via the tag: Display SVG image...
Read more >
Radzen Blazor Chart column description styling
I've managed to rotate the labels by using the currently available API. Here is how: <RadzenCategoryAxis> <RadzenTicks> <Template> <text ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found