-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Conversation
Reviewer's GuideThis PR adds manual trigger support to Tooltip and Popover components by exposing Show, Hide, and Toggle methods, updates documentation and demos to illustrate manual usage, refactors CSS class construction, and adds unit tests for the new functionality. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6663 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31667 31672 +5
Branches 4459 4459
=========================================
+ Hits 31667 31672 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/Tooltips.razor:103` </location>
<code_context>
+ <Popover Title="@Title" Content="@Content" IsHtml="true" Trigger="manual" @ref="_popover">
+ <i class="fa-solid fa-flag" style="cursor: pointer;"></i>
+ </Popover>
+ <Button Text="Tigger" OnClickWithoutRender="ToggleShow"></Button>
+</DemoBlock>
+
</code_context>
<issue_to_address>
Typo in button text: 'Tigger' should be 'Trigger'.
Please update the button text to 'Trigger'.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
<Button Text="Tigger" OnClickWithoutRender="ToggleShow"></Button>
=======
<Button Text="Trigger" OnClickWithoutRender="ToggleShow"></Button>
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/BootstrapBlazor.Server/Components/Samples/Popovers.razor:81` </location>
<code_context>
+ <Popover Title="@Title" Content="@Content" IsHtml="true" Trigger="manual" @ref="_popover">
+ <i class="fa-solid fa-flag" style="cursor: pointer;"></i>
+ </Popover>
+ <Button Text="Tigger" OnClickWithoutRender="ToggleShow"></Button>
+</DemoBlock>
+
</code_context>
<issue_to_address>
Typo in button text: 'Tigger' should be 'Trigger'.
Please update the button text to 'Trigger'.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
<Button Text="Tigger" OnClickWithoutRender="ToggleShow"></Button>
=======
<Button Text="Trigger" OnClickWithoutRender="ToggleShow"></Button>
>>>>>>> REPLACE
</suggested_fix>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@sourcery-ai review |
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.
Pull Request Overview
This PR adds manual trigger support to Tooltip and Popover components, allowing programmatic control of their visibility states through new Show(), Hide(), and Toggle() methods.
- Added manual trigger functionality with Show/Hide/Toggle methods for both Tooltip and Popover components
- Implemented corresponding JavaScript functions to control Bootstrap tooltip/popover instances
- Added demonstration samples and localization for the new manual trigger feature
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/BootstrapBlazor/Components/Tooltip/Tooltip.razor.cs |
Added Show/Hide/Toggle methods and refactored CSS class handling |
src/BootstrapBlazor/Components/Tooltip/Tooltip.razor.js |
Implemented JavaScript functions for manual tooltip control |
src/BootstrapBlazor/Components/Popover/Popover.razor.js |
Added JavaScript functions for manual popover control |
src/BootstrapBlazor/Components/Tooltip/ITooltip.cs |
Updated documentation to include manual trigger mode |
test/UnitTest/Components/TooltipTest.cs |
Added unit test for manual trigger functionality |
Sample files | Added demonstration components and localization strings |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Hey there - I've reviewed your changes - here's some feedback:
- Consider extracting the duplicated show/hide/toggle JavaScript functions for Tooltip and Popover into a shared helper to reduce code duplication and ensure consistent behavior.
- The CSS class construction (
ClassString
vsCustomClassString
) differs between Tooltip and Popover—unify the builder logic and property naming to simplify attribute binding and avoid confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the duplicated show/hide/toggle JavaScript functions for Tooltip and Popover into a shared helper to reduce code duplication and ensure consistent behavior.
- The CSS class construction (`ClassString` vs `CustomClassString`) differs between Tooltip and Popover—unify the builder logic and property naming to simplify attribute binding and avoid confusion.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/Tooltip/Tooltip.razor.js:23` </location>
<code_context>
}
}
+export function show(id, delay) {
+ const el = document.getElementById(id)
+ if (el) {
+ const pop = bootstrap.Popover.getInstance(el);
+ if (pop) {
+ setTimeout(() => {
+ pop.show();
+ }, delay || 0);
+ }
+ }
</code_context>
<issue_to_address>
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.
</issue_to_address>
### Comment 2
<location> `src/BootstrapBlazor/Components/Popover/Popover.razor.js:12` </location>
<code_context>
}
}
+export function show(id, delay) {
+ const el = document.getElementById(id)
+ if (el) {
+ const pop = bootstrap.Popover.getInstance(el);
+ if (pop) {
+ setTimeout(() => {
+ pop.show();
+ }, delay || 0);
+ }
+ }
</code_context>
<issue_to_address>
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.
</issue_to_address>
### Comment 3
<location> `test/UnitTest/Components/TooltipTest.cs:183` </location>
<code_context>
+ [Fact]
+ public async Task Toggle_Ok()
+ {
+ var cut = Context.RenderComponent<Tooltip>(pb =>
+ {
+ pb.Add(a => a.Title, "test_tooltip");
+ pb.Add(a => a.Trigger, "manual");
+ });
+ await cut.InvokeAsync(() => cut.Instance.Show());
</code_context>
<issue_to_address>
Missing edge case tests for manual trigger with delay parameter.
Please add tests for Show, Hide, and Toggle that specify various delay values (0, positive, negative) to verify correct handling of the delay parameter.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
export function show(id, delay) { | ||
const tip = Data.get(id) | ||
const { tooltip } = tip; | ||
|
||
setTimeout(() => { | ||
tooltip.show(); | ||
}, delay || 0); |
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.
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 show(id, delay) { | ||
const el = document.getElementById(id) | ||
if (el) { | ||
const pop = bootstrap.Popover.getInstance(el); | ||
if (pop) { | ||
setTimeout(() => { | ||
pop.show(); | ||
}, delay || 0); |
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.
var cut = Context.RenderComponent<Tooltip>(pb => | ||
{ | ||
pb.Add(a => a.Title, "test_tooltip"); | ||
pb.Add(a => a.Trigger, "manual"); |
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 (testing): Missing edge case tests for manual trigger with delay parameter.
Please add tests for Show, Hide, and Toggle that specify various delay values (0, positive, negative) to verify correct handling of the delay parameter.
Link issues
fixes #6662
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Implement manual trigger support for Tooltip and Popover components, enabling programmatic Show/Hide/Toggle operations and integrating corresponding JS interop, interface updates, sample demos, and tests.
New Features:
Enhancements:
Documentation:
Tests: