Skip to content

Conversation

ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Aug 21, 2025

Link issues

fixes #6662

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

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:

  • Add Show, Hide, and Toggle methods on Tooltip and Popover components for manual trigger control
  • Implement corresponding JavaScript interop functions for manual tooltip and popover operations

Enhancements:

  • Refactor CSS class string generation in Tooltip and Popover to use default base classes
  • Update XML documentation to use inheritdoc and extend ITooltip.Trigger remarks
  • Introduce TooltipContent component to demonstrate content-aware toggling

Documentation:

  • Add manual trigger demo sections for Tooltip and Popover in the sample pages

Tests:

  • Add unit test verifying manual Show/Hide/Toggle functionality for Tooltip

@Copilot Copilot AI review requested due to automatic review settings August 21, 2025 05:14
@bb-auto bb-auto bot added the enhancement New feature or request label Aug 21, 2025
@bb-auto bb-auto bot added this to the 9.9.0 milestone Aug 21, 2025
Copy link
Contributor

sourcery-ai bot commented Aug 21, 2025

Reviewer's Guide

This 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

Change Details Files
Expose programmatic Show, Hide, and Toggle methods for Tooltip and Popover components to enable manual triggering.
  • Add Show, Hide, and Toggle methods to Tooltip.razor.cs and Popover.razor.cs.
  • Implement corresponding JavaScript interop functions in Tooltip.razor.js and Popover.razor.js.
src/BootstrapBlazor/Components/Tooltip/Tooltip.razor.cs
src/BootstrapBlazor/Components/Popover/Popover.razor.cs
src/BootstrapBlazor/Components/Tooltip/Tooltip.razor.js
src/BootstrapBlazor/Components/Popover/Popover.razor.js
Update demos and documentation to showcase manual trigger usage for Tooltip and Popover.
  • Add manual trigger demo blocks in Tooltips.razor and Popovers.razor.
  • Implement ToggleShow methods in Tooltips.razor.cs and Popovers.razor.cs for demo interaction.
  • Add TooltipContent component for demo purposes.
  • Update localization files for new demo content.
src/BootstrapBlazor.Server/Components/Samples/Tooltips.razor
src/BootstrapBlazor.Server/Components/Samples/Tooltips.razor.cs
src/BootstrapBlazor.Server/Components/Samples/Popovers.razor
src/BootstrapBlazor.Server/Components/Samples/Popovers.razor.cs
src/BootstrapBlazor.Server/Components/Components/TooltipContent.razor
src/BootstrapBlazor.Server/Components/Components/TooltipContent.razor.cs
src/BootstrapBlazor.Server/Locales/en-US.json
src/BootstrapBlazor.Server/Locales/zh-CN.json
Refactor CSS class construction for Tooltip and Popover components.
  • Change ClassString and CustomClassString construction to use CssBuilder with updated logic.
src/BootstrapBlazor/Components/Tooltip/Tooltip.razor.cs
src/BootstrapBlazor/Components/Popover/Popover.razor.cs
src/BootstrapBlazor/Components/Popover/Popover.razor
src/BootstrapBlazor/Components/Tooltip/Tooltip.razor
Update ITooltip interface and documentation to include manual trigger mode and clarify delay behavior.
  • Document manual trigger option and related methods in ITooltip.cs.
src/BootstrapBlazor/Components/Tooltip/ITooltip.cs
Add unit test to verify manual Show/Hide/Toggle behavior for Tooltip.
  • Add Toggle_Ok test in TooltipTest.cs to cover new methods.
test/UnitTest/Components/TooltipTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6662 Add support for manual trigger mode to Tooltip component, allowing tooltips to be shown, hidden, or toggled programmatically.
#6662 Expose programmatic control methods (Show, Hide, Toggle) on Tooltip component and document their usage.
#6662 Provide demo/sample and unit test coverage for manual trigger functionality in Tooltip component.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copilot

This comment was marked as outdated.

Copy link

codecov bot commented Aug 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (24726c3) to head (1168f4c).
⚠️ Report is 1 commits behind head on main.

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     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Aug 21, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang
Copy link
Member Author

@sourcery-ai review

@ArgoZhang ArgoZhang requested a review from Copilot August 21, 2025 05:23
Copy link

@Copilot Copilot AI left a 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.

@ArgoZhang ArgoZhang merged commit 7d225d9 into main Aug 21, 2025
7 checks passed
@ArgoZhang ArgoZhang deleted the feat-tooltip branch August 21, 2025 05:25
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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 vs CustomClassString) 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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +23 to +29
export function show(id, delay) {
const tip = Data.get(id)
const { tooltip } = tip;

setTimeout(() => {
tooltip.show();
}, delay || 0);
Copy link
Contributor

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.

Comment on lines +12 to +19
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);
Copy link
Contributor

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.

Comment on lines +183 to +186
var cut = Context.RenderComponent<Tooltip>(pb =>
{
pb.Add(a => a.Title, "test_tooltip");
pb.Add(a => a.Trigger, "manual");
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(Tooltip): support manual trigger
1 participant