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

Blazor NavLink doesn't work if @ is used in class attribute #8557

Closed
1 task done
Eptagone opened this issue Apr 3, 2023 · 1 comment
Closed
1 task done

Blazor NavLink doesn't work if @ is used in class attribute #8557

Eptagone opened this issue Apr 3, 2023 · 1 comment
Labels
area-blazor ✔️ resolution: duplicate This issue or pull request already exists

Comments

@Eptagone
Copy link

Eptagone commented Apr 3, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hello friends. I needs to use the @ in the class attribute of NavLink but it doesn't work.
I'm using Tailwind with their container queries classes in my Blazor Server project. The container queries classes have @ into their class names. I'm using the double @ as follows:

<NavLink class="current:text-primary-700 @@sm:pl-4" href="">
    <span>Home</span>
</NavLink>

But i'm getting an error with the message: Component attributes do not support complex content (mixed C# and markup). Attribute: 'class', text: 'current:text-primary-700 @sm:pl-4'.

It works with normal html tags like div but not for NavLink.

At the moment I think adding another div would work for what I'm doing but I'd prefer to keep the number of html elements as low as possible in my project.

Expected Behavior

I just want that my anchor tag to be rendered

<a class="current:text-primary-700 @sm:pl-4" href>
    <span>Home</span>
</a>

Steps To Reproduce

In any Blazor project, try using an @ in the class attribute of any NavLink.

Exceptions (if any)

CSC : error RZ9986: Component attributes do not support complex content (mixed C# and markup).

.NET Version

6.0.15

Anything else?

.NET SDK:
 Version:   7.0.202
 Commit:    6c74320bc3

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.202\

Host:
  Version:      7.0.4
  Architecture: x64
  Commit:       0a396acafe

.NET SDKs installed:
  7.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]     
  Microsoft.WindowsDesktop.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]      

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
@MackinnonBuck MackinnonBuck transferred this issue from dotnet/aspnetcore Apr 3, 2023
@ghost ghost added the untriaged label Apr 3, 2023
@davidwengier
Copy link
Member

Thanks for reporting this issue. We are tracking this over at #7349 so I'm going to close this as a duplicate.

@davidwengier davidwengier closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2023
@ghost ghost removed the untriaged label Apr 3, 2023
@davidwengier davidwengier added the ✔️ resolution: duplicate This issue or pull request already exists label Apr 3, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor ✔️ resolution: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants