ButtonType.Link - href not rendered when there's a custom attribute and an HTTP call

未关闭
#1,174 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp
领域
frontend

调研方向

Start at the Blazor Button component that renders ButtonType.Link, then trace how it combines the To parameter with unmatched custom attributes during rendering. Reproduce the reported behavior with the supplied component and HTTP call, comparing it with the cases where either the custom attribute or the call is removed. Done means the rendered link retains the expected href in the reported scenario.

由索引模型根据 Issue 内容生成。

描述

Describe the bug

When the following is rendered, the <a> tag doesn't have an href attribute:

@page "/counter"
@using BlazorBootstrap
@inject HttpClient HttpClient;

<Button Type="@ButtonType.Link" To="/my-route" moo="moo">Moo</Button>

@code {
    protected override async Task OnInitializedAsync()
    {
        await HttpClient.GetStringAsync("https://jsonplaceholder.typicode.com/posts/1");
    }
}

If I remove the custom moo attribute or comment out the HttpClient call in OnInitializedAsync, then the button/link is rendered properly.

To Reproduce
Steps to reproduce the behavior:

  1. Add a Button with Type=ButtonType.Link and a URL for To and a custom HTML attribute
  2. Add an HttpClient call in OnInitializedAsync()
  3. Render the page

Expected behavior
Clicking the button should redirect to the URL specified in the To property.

Screenshots
If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

  • .NET Version: .NET 9
  • BlazorBootstrap: 3.4.0
  • Blazor WebAssembly / Server: WebAssembly
  • Blazor Interactive Render Mode: Auto
  • Blazor Interactivity Location: Per page/component

Sample code
See above

GitHub repo
GitHub repo with minimal code to reproduce the issue.

Desktop (please complete the following information):

  • OS: macOS, Windows
  • Browser: Chrome
  • Version: 140.0.7339.80

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

主要语言
HTML
星标
1.2k
派生
111
平均合并
4 分钟
30 天内合并 PR
55

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

vikramlearning/blazorbootstrap 的其他 Issue

查看 vikramlearning/blazorbootstrap 的全部 Issue

相似的 Issue

更多 Web Dev Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。