Skip to content

feat(Mask): add AppendToBody parameter#7834

Merged
ArgoZhang merged 15 commits intomainfrom
feat-mask
Apr 3, 2026
Merged

feat(Mask): add AppendToBody parameter#7834
ArgoZhang merged 15 commits intomainfrom
feat-mask

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Apr 3, 2026

Link issues

fixes #7833

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

Introduce a configurable option for Mask placement and improve its lifecycle cleanup with service unregistration.

New Features:

  • Add a Mask option to control whether the mask element is appended to the document body.

Enhancements:

  • Unregister Mask components from MaskService during asynchronous disposal to avoid stale registrations.

Chores:

  • Normalize file headers and encoding for Mask-related source files.

Copilot AI review requested due to automatic review settings April 3, 2026 11:25
@bb-auto bb-auto bot added the documentation Improvements or additions to documentation label Apr 3, 2026
@bb-auto bb-auto bot added this to the v10.5.0 milestone Apr 3, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Apr 3, 2026

Reviewer's Guide

Extends the Mask component options with an AppendToBody flag that controls whether the mask element is appended to document.body, wires this option through the .NET and JS layers, and ensures the mask instance unregisters from MaskService on disposal.

Sequence diagram for Mask update with AppendToBody option

sequenceDiagram
    actor User
    participant Mask as MaskComponent
    participant MaskService
    participant JS as JSInterop
    participant Script as Mask_razor_js
    participant DOM

    User->>MaskService: RequestMask(option)
    MaskService-->>Mask: Show(option)
    Mask->>Mask: _options = option
    Mask->>JS: InvokeVoidAsync(update, id, { show, containerId, selector, appendToBody })
    JS-->>Script: update(id, options)

    Script->>DOM: const mask = getElementById(id)
    alt mask exists
        Script->>DOM: el = querySelector([data-bb-mask=id])
        Script->>DOM: container = getContainerBySelector(options)
        alt container exists
            Script->>DOM: container.appendChild(el)
        else appendToBody is true
            Script->>DOM: document.body.appendChild(el)
        else appendToBody is false
            Script-->>DOM: no reparenting
        end
    else mask does not exist
        Script-->>JS: return
    end

    User->>Mask: DisposeAsync(disposing: true)
    Mask->>MaskService: UnRegister(this)
    Mask->>JS: Dispose module via base.DisposeAsync
Loading

Updated class diagram for Mask and MaskOption with AppendToBody and disposal

classDiagram
    class BootstrapModuleComponentBase

    class Mask {
        - MaskOption _options
        + Task Show(MaskOption option)
        + Task CloseAsync()
        + ValueTask DisposeAsync(bool disposing)
    }

    class MaskOption {
        + string ContainerId
        + string Selector
        + bool AppendToBody = true
    }

    class MaskService {
        + void Register(Mask mask)
        + void UnRegister(Mask mask)
    }

    Mask --|> BootstrapModuleComponentBase
    Mask --> MaskOption : uses
    MaskService ..> Mask : manages
Loading

File-Level Changes

Change Details Files
Wire new AppendToBody option from Mask component to JavaScript mask update logic.
  • Pass AppendToBody from Mask.razor.cs when invoking JS update via InvokeVoidAsync.
  • Update JS update(id, options) to destructure appendToBody from options.
  • Change JS behavior so the mask DOM element is appended to document.body only when no container is found and appendToBody is explicitly true.
src/BootstrapBlazor/Components/Mask/Mask.razor.cs
src/BootstrapBlazor/Components/Mask/Mask.razor.js
Introduce AppendToBody configuration option on MaskOption with documentation and default behavior.
  • Add AppendToBody boolean property to MaskOption with XML documentation in Chinese and English.
  • Set default value of AppendToBody to true to preserve previous behavior when not configured.
src/BootstrapBlazor/Components/Mask/MaskOption.cs
Improve Mask component lifecycle handling and API clarity.
  • Refactor CloseAsync to an expression-bodied method that delegates to Show(null).
  • Override DisposeAsync to call base.DisposeAsync and unregister the mask instance from MaskService when disposing.
src/BootstrapBlazor/Components/Mask/Mask.razor.cs
Minor non-functional file header/encoding cleanups.
  • Normalize BOM/license header in Masks.razor.cs.
  • Normalize BOM/first-line encoding marker in Mask.razor.
src/BootstrapBlazor.Server/Components/Samples/Masks.razor.cs
src/BootstrapBlazor/Components/Mask/Mask.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#7833 Update the Mask component documentation to better describe its behavior and options (code-level/XML docs or related documentation).

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

Copy link
Copy Markdown
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 - I've found 1 issue, and left some high level feedback:

  • In MaskOption.AppendToBody XML docs, the <vesion> tag appears to be misspelled and may not be recognized by your tooling; consider correcting or removing it.
  • The override of DisposeAsync(bool disposing) mixes <inheritdoc/> inside <summary> and has an empty <param> tag; consider simplifying the XML comment (e.g., just <inheritdoc />) to avoid misleading or redundant documentation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `MaskOption.AppendToBody` XML docs, the `<vesion>` tag appears to be misspelled and may not be recognized by your tooling; consider correcting or removing it.
- The override of `DisposeAsync(bool disposing)` mixes `<inheritdoc/>` inside `<summary>` and has an empty `<param>` tag; consider simplifying the XML comment (e.g., just `<inheritdoc />`) to avoid misleading or redundant documentation.

## Individual Comments

### Comment 1
<location path="src/BootstrapBlazor/Components/Mask/MaskOption.cs" line_range="51-55" />
<code_context>
+    /// <summary>
+    /// <para lang="zh">获得/设置 是否将遮罩追加到 body 元素 默认 true</para>
+    /// <para lang="en">Gets or sets whether to append the mask to the body element. Default true</para>
+    /// <para>v<vesion>10.5.1</vesion></para>
+    /// </summary>
+    public bool AppendToBody { get; set; } = true;
 }
</code_context>
<issue_to_address>
**suggestion (typo):** Fix the `<vesion>` tag typo and redundant leading `v` in the XML doc.

The `vesion` tag appears to be a typo, and the leading `v` makes the XML odd. Use a proper tag (e.g. `<version>10.5.1</version>`) that your tooling recognizes so XML parsers and doc generators can handle it correctly.

```suggestion
    /// <para lang="zh">获得/设置 是否将遮罩追加到 body 元素 默认 true</para>
    /// <para lang="en">Gets or sets whether to append the mask to the body element. Default true</para>
    /// <para><version>10.5.1</version></para>
    /// </summary>
    public bool AppendToBody { get; set; } = true;
```
</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 +51 to +55
/// <para lang="zh">获得/设置 是否将遮罩追加到 body 元素 默认 true</para>
/// <para lang="en">Gets or sets whether to append the mask to the body element. Default true</para>
/// <para>v<vesion>10.5.1</vesion></para>
/// </summary>
public bool AppendToBody { get; set; } = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (typo): Fix the <vesion> tag typo and redundant leading v in the XML doc.

The vesion tag appears to be a typo, and the leading v makes the XML odd. Use a proper tag (e.g. <version>10.5.1</version>) that your tooling recognizes so XML parsers and doc generators can handle it correctly.

Suggested change
/// <para lang="zh">获得/设置 是否将遮罩追加到 body 元素 默认 true</para>
/// <para lang="en">Gets or sets whether to append the mask to the body element. Default true</para>
/// <para>v<vesion>10.5.1</vesion></para>
/// </summary>
public bool AppendToBody { get; set; } = true;
/// <para lang="zh">获得/设置 是否将遮罩追加到 body 元素 默认 true</para>
/// <para lang="en">Gets or sets whether to append the mask to the body element. Default true</para>
/// <para><version>10.5.1</version></para>
/// </summary>
public bool AppendToBody { get; set; } = true;

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7834   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          764       764           
  Lines        34147     34165   +18     
  Branches      4701      4704    +3     
=========================================
+ Hits         34147     34165   +18     
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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

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

Updates the Mask component API and related implementation to support controlling whether the mask element is appended to document.body, along with some lifecycle and packaging adjustments.

Changes:

  • Add AppendToBody option to MaskOption and pass it through Blazor → JS interop.
  • Update Mask.razor.js placement logic to conditionally append to body.
  • Unregister Mask from MaskService on dispose; bump package version and remove BOM/formatting artifacts in a few files.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/BootstrapBlazor/Components/Mask/MaskOption.cs Adds AppendToBody option (with XML doc update).
src/BootstrapBlazor/Components/Mask/Mask.razor.js Updates DOM placement logic based on appendToBody.
src/BootstrapBlazor/Components/Mask/Mask.razor.cs Passes new option to JS and unregisters from MaskService on dispose.
src/BootstrapBlazor/Components/Mask/Mask.razor Removes BOM/whitespace artifact (no functional change).
src/BootstrapBlazor/BootstrapBlazor.csproj Bumps library version.
src/BootstrapBlazor.Server/Components/Samples/Masks.razor.cs Removes BOM/whitespace artifact (no functional change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/// <summary>
/// <para lang="zh">获得/设置 是否将遮罩追加到 body 元素 默认 true</para>
/// <para lang="en">Gets or sets whether to append the mask to the body element. Default true</para>
/// <para>v<vesion>10.5.1</vesion></para>
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XML doc tag appears misspelled: <vesion> isn’t used elsewhere in the codebase (convention is <version>). This will likely break doc tooling / consistency; please change to <version>.

Suggested change
/// <para>v<vesion>10.5.1</vesion></para>
/// <para>v<version>10.5.1</version></para>

Copilot uses AI. Check for mistakes.
Comment on lines +17 to 19
else if (appendToBody === true) {
document.body.appendChild(el);
}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When appendToBody is false and no container is resolved, the mask element stays inside the <template> and therefore won’t be rendered/visible even when show is true. Consider appending to a sensible default (e.g., mask.parentElement) or enforcing that containerId/selector must be set when appendToBody is false (with a clear error).

Copilot uses AI. Check for mistakes.
Comment on lines 3 to 5
<PropertyGroup>
<Version>10.5.1-beta01</Version>
<Version>10.5.1-beta04</Version>
</PropertyGroup>
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR title/linked issue indicate a documentation-only change, but this PR also introduces behavioral changes (new AppendToBody option, JS logic changes) and bumps the package version. Please align the PR metadata/title/description with the actual scope, or split version bump/behavior changes into a separate PR.

Copilot uses AI. Check for mistakes.
@ArgoZhang ArgoZhang changed the title doc(Mask): update Mask documentation feat(Mask): add AppendToBody parameter Apr 3, 2026
@ArgoZhang ArgoZhang added enhancement New feature or request and removed documentation Improvements or additions to documentation labels Apr 3, 2026
@ArgoZhang ArgoZhang merged commit be9a680 into main Apr 3, 2026
4 checks passed
@ArgoZhang ArgoZhang deleted the feat-mask branch April 3, 2026 15:04
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(Mask): add AppendToBody parameter

2 participants