Skip to content

[8.0.100-preview.4.23211.1] Anchor tag behavior changed when setting herf="#" in blazor app #47682

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

Closed
1 task done
Junjun-zhao opened this issue Apr 13, 2023 · 3 comments
Closed
1 task done
Assignees
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@Junjun-zhao
Copy link
Member

Junjun-zhao commented Apr 13, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In dotnet-sdk-8.0.100-preview.4.23211.1, when set herf="#" in blazor page, if user click the link, it will stay on current page. But in previous version, it will navigate to main page.

Application Name: Blazorise
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-8.0.100-preview.4.23211.1
App Source checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1799823
Or Github link:
https://github.com/Megabit/Blazorise

Expected Behavior

It navigates to Home page, the url is "https://localhost:5000/#".

Steps To Reproduce

Repro steps:

1.Create a default Blazor Server app with Visual Studio.
2. Add "<a href="#">Test Link</a>" on Counter.razor.
3. Build the project.
4. Open BlazorApp1.runtimeconfig.json to change the runtime version to let the app run against 8.0.100-preview.4.23211.1:

    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "8.0.0-preview.4.23210.1"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "8.0.0-preview.4.23207.6"
      }
]
  1. Launch the app.
  2. Navigate to Counter page.
  3. Click the "Test Link".

Actual Result:

It stays on current page, when click the link, the url is "https://localhost:5000/counter#". When mouse hover to the link, it shows https://localhost:5000/# .

Exceptions (if any)

No response

.NET Version

8.0.100-preview.4.23211.1

Anything else?

Findings

  • In .NET Framework web app, if we add <a href="#">Test Link</a> on the page, when click on it, it stays on current page.

  • In 8.0.100-preview.4.23211.1, when mouse hover to the link, it shows https://localhost:5000/# But when click it, it goes to https://localhost:5000/counter#

@dotnet-actwx-bot @dotnet/compat

@surayya-MS
Copy link
Member

surayya-MS commented Apr 13, 2023

Thanks for the report @Junjun-zhao !

Staying on the page by clicking <a href="#">Test Link</a> is a new expected behavior that was introduced recently.

when mouse hover to the link, it shows https://localhost:5000/# But when click it, it goes to https://localhost:5000/counter#

However this is not the expected behavior. It should show https://localhost:5000/counter#

@surayya-MS
Copy link
Member

@Junjun-zhao, after the investigation it turned up to be a regression. I changed it back so the scenario that you described in this issue should work as it did before.

@Junjun-zhao
Copy link
Member Author

 Verified it and the issue is fixed on dotnet-sdk-8.0.100-preview.4.23253.2

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

2 participants