-
-
Notifications
You must be signed in to change notification settings - Fork 362
feat(Tooltip): support manual trigger #6663
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0e674bf
feat: 增加 show/hide 方法
ArgoZhang f9623be
feat: 增加 toggle 方法
ArgoZhang e301a18
doc: 更新 delay 参数说明文档
ArgoZhang 8672eab
feat: 增加 Show/Hide/Toggle 实例方法
ArgoZhang 03261a8
feat: 增加 IToggle 接口
ArgoZhang f383f47
refactor: 调整 Popover 组件支持 Toggle 方法
ArgoZhang 9a4a26f
doc: 更新 Tooltip 示例
ArgoZhang f918e7a
revert: 撤销 IToggle 接口
ArgoZhang 45c2bdf
doc: 更新示例代码
ArgoZhang cb4a9d2
revert: 撤销更新
ArgoZhang 51739bb
doc: 更新文档
ArgoZhang 04264dc
feat: 增加状态切换逻辑
ArgoZhang 3d09771
doc: 更新 Popover 示例
ArgoZhang d3d75fc
chore: bump version 9.9.3-beta03
ArgoZhang 39e82dc
doc: 更正单词拼写错误
ArgoZhang 41a7328
test: 补充单元测试
ArgoZhang ec6d42b
refactor: 精简代码
ArgoZhang 1168f4c
doc: 更正单词拼写错误
ArgoZhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/BootstrapBlazor.Server/Components/Components/TooltipContent.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<i class="fa-solid fa-flag" style="cursor: pointer;" @onclick="ToggleShow" /> |
25 changes: 25 additions & 0 deletions
25
src/BootstrapBlazor.Server/Components/Components/TooltipContent.razor.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the Apache 2.0 License | ||
// See the LICENSE file in the project root for more information. | ||
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone | ||
|
||
namespace BootstrapBlazor.Server.Components.Components; | ||
|
||
/// <summary> | ||
/// TooltipContent 组件用于显示 Tooltip 的内容 | ||
/// </summary> | ||
public partial class TooltipContent | ||
{ | ||
[CascadingParameter] | ||
private Tooltip? Tooltip { get; set; } | ||
|
||
private async Task ToggleShow() | ||
{ | ||
if (Tooltip == null) | ||
{ | ||
return; | ||
} | ||
|
||
await Tooltip.Toggle(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,33 @@ export function init(id) { | |
} | ||
} | ||
|
||
export function show(id, delay) { | ||
const tip = Data.get(id) | ||
const { tooltip } = tip; | ||
|
||
setTimeout(() => { | ||
tooltip.show(); | ||
}, delay || 0); | ||
Comment on lines
+23
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): No null/undefined check for 'tip' or 'tooltip' in show/hide/toggle functions. Add validation to ensure 'tip' and 'tooltip' exist before invoking methods to prevent runtime errors. |
||
} | ||
|
||
export function hide(id, delay) { | ||
const tip = Data.get(id) | ||
const { tooltip } = tip; | ||
|
||
setTimeout(() => { | ||
tooltip.hide(); | ||
}, delay || 0); | ||
} | ||
|
||
export function toggle(id, delay) { | ||
const tip = Data.get(id) | ||
const { tooltip } = tip; | ||
|
||
setTimeout(() => { | ||
tooltip.toggle(); | ||
}, delay || 0); | ||
} | ||
|
||
export function dispose(id) { | ||
const tip = Data.get(id) | ||
Data.remove(id) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Popover show/hide/toggle functions do not handle missing Popover instance gracefully.
Consider adding a log or error handler when getInstance returns null to improve debugging and user feedback.