mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-11-30 02:58:37 +08:00
!2583 feat(#I4ZSLV): add tooltip api on ButtonBase
* test: 增加单元测试 * feat: 增加显示/销毁 Tooltip 方法
This commit is contained in:
parent
5072fa7760
commit
cfd1d1fb09
@ -211,4 +211,29 @@ public abstract class ButtonBase : TooltipComponentBase
|
||||
IsDisabled = disable;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示 Tooltip 方法
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public virtual async Task ShowTooltip(string message)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Id))
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync(null, "bb_tooltip", Id, "show", message, "auto", false, "focus");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁 Tooltip 方法
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual async Task RemoveTooltip()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Id))
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync(null, "bb_tooltip", Id, "dispose");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -321,4 +321,18 @@ public class ButtonTest : BootstrapBlazorTestBase
|
||||
await tcs.Task;
|
||||
Assert.True(valid);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShowTooltip_Ok()
|
||||
{
|
||||
var cut = Context.RenderComponent<Button>();
|
||||
await cut.InvokeAsync(() => cut.Instance.ShowTooltip("Test"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RemoveTooltip_Ok()
|
||||
{
|
||||
var cut = Context.RenderComponent<Button>();
|
||||
await cut.InvokeAsync(() => cut.Instance.RemoveTooltip());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user