Skip to content

Comments

fix(ButtonUpload): add ShowDeleteButton parameter#7590

Merged
ArgoZhang merged 3 commits intomainfrom
fix-button
Jan 27, 2026
Merged

fix(ButtonUpload): add ShowDeleteButton parameter#7590
ArgoZhang merged 3 commits intomainfrom
fix-button

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Jan 27, 2026

Link issues

fixes #7587

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

Add configurable delete button visibility to upload components and centralize its handling in the preview list.

New Features:

  • Introduce a ShowDeleteButton parameter on ButtonUpload, CardUpload, DropUpload, and UploadPreviewList to control whether the delete button is displayed.

Enhancements:

  • Move delete button rendering responsibility into UploadPreviewList so it respects the new ShowDeleteButton parameter.

Copilot AI review requested due to automatic review settings January 27, 2026 06:22
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 27, 2026

Reviewer's Guide

Adds a configurable ShowDeleteButton parameter to upload components and wires it through to the shared UploadPreviewList so consumers can toggle visibility of the per-file delete action across ButtonUpload, CardUpload, and DropUpload.

Class diagram for ShowDeleteButton in upload components

classDiagram
    direction LR

    class UploadBase_TValue_ {
    }

    class FileListUploadBase_TValue_ {
    }

    class ButtonUpload_TValue_ {
        +bool ShowDeleteButton
    }

    class CardUpload_TValue_ {
        +bool ShowDeleteButton
    }

    class DropUpload {
        +bool ShowDeleteButton
    }

    class UploadPreviewList {
        +bool ShowDownloadButton
        +bool ShowDeleteButton
    }

    UploadBase_TValue_ <|-- FileListUploadBase_TValue_
    FileListUploadBase_TValue_ <|-- ButtonUpload_TValue_
    FileListUploadBase_TValue_ <|-- CardUpload_TValue_

    ButtonUpload_TValue_ --> UploadPreviewList : passes_ShowDeleteButton
    DropUpload --> UploadPreviewList : passes_ShowDeleteButton
    CardUpload_TValue_ --> UploadPreviewList : uses_internally_for_delete
Loading

Flow diagram for ShowDeleteButton propagation to UploadPreviewList

flowchart LR
    A[Parent component sets ShowDeleteButton on ButtonUpload or DropUpload] --> B[ButtonUpload_TValue_ or DropUpload receives ShowDeleteButton parameter]
    B --> C[ButtonUpload_TValue_ or DropUpload renders UploadPreviewList]
    C --> D[ShowDeleteButton parameter is forwarded to UploadPreviewList]
    D --> E[UploadPreviewList evaluates ShowDeleteButton]
    E -->|ShowDeleteButton == true| F[Render delete icon with OnFileDelete handler]
    E -->|ShowDeleteButton == false| G[Do not render delete icon]
Loading

File-Level Changes

Change Details Files
Introduce ShowDeleteButton parameter on upload entry components and propagate it to the preview list.
  • Add [Parameter] ShowDeleteButton with default true on ButtonUpload and DropUpload to control delete icon visibility.
  • Add [Parameter] ShowDeleteButton with default false on CardUpload matching previous behavior from FileListUploadBase.
  • Remove ShowDeleteButton parameter from FileListUploadBase to avoid unused or redundant configuration.
  • Add [Parameter] ShowDeleteButton on UploadPreviewList and gate rendering of the delete icon with an @if block in the markup.
  • Pass ShowDeleteButton from ButtonUpload and DropUpload into UploadPreviewList so the new parameter actually affects the rendered UI.
src/BootstrapBlazor/Components/Upload/ButtonUpload.razor.cs
src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs
src/BootstrapBlazor/Components/Upload/DropUpload.razor.cs
src/BootstrapBlazor/Components/Upload/FileListUploadBase.cs
src/BootstrapBlazor/Components/Upload/UploadPreviewList.razor
src/BootstrapBlazor/Components/Upload/UploadPreviewList.razor.cs
src/BootstrapBlazor/Components/Upload/ButtonUpload.razor
src/BootstrapBlazor/Components/Upload/DropUpload.razor
src/BootstrapBlazor/Components/Upload/CardUpload.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#7587 Make the ShowDeleteButton parameter control visibility of the delete icon in the upload preview list used by ButtonUpload (i.e., only render the delete button when ShowDeleteButton is true).

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

@bb-auto bb-auto bot added the bug Something isn't working label Jan 27, 2026
@bb-auto bb-auto bot added this to the v10.2.0 milestone Jan 27, 2026
@ArgoZhang ArgoZhang changed the title feat(ButtonUpload): add ShowDeleteButton parameter fix(ButtonUpload): add ShowDeleteButton parameter Jan 27, 2026
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 - I've found 1 issue, and left some high level feedback:

  • The new ShowDeleteButton parameter on CardUpload<TValue> is never passed through to UploadPreviewList in CardUpload.razor, so setting it on CardUpload currently has no effect; consider binding ShowDeleteButton on the preview list as done for ButtonUpload and DropUpload.
  • With ShowDeleteButton now defined on multiple upload components, consider centralizing this parameter (e.g., in a shared base class or interface) to avoid duplication and keep behavior consistent across the different upload variants.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `ShowDeleteButton` parameter on `CardUpload<TValue>` is never passed through to `UploadPreviewList` in `CardUpload.razor`, so setting it on `CardUpload` currently has no effect; consider binding `ShowDeleteButton` on the preview list as done for `ButtonUpload` and `DropUpload`.
- With `ShowDeleteButton` now defined on multiple upload components, consider centralizing this parameter (e.g., in a shared base class or interface) to avoid duplication and keep behavior consistent across the different upload variants.

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor/Components/Upload/UploadPreviewList.razor.cs:99-104` </location>
<code_context>
 /// </summary>
 public partial class ButtonUpload<TValue>
 {
+    /// <summary>
+    /// <para lang="zh">获得/设置 是否显示删除按钮,默认 true</para>
+    /// <para lang="en">Gets or sets whether to display the delete button. Default is true</para>
</code_context>

<issue_to_address>
**question:** The effective default for ShowDeleteButton differs between UploadPreviewList and the higher-level upload components; is that divergence intentional?

Here it defaults to `false` via the CLR default, matching the XML docs, while `ButtonUpload` and `DropUpload` now set `ShowDeleteButton { get; set; } = true;` and pass that through. So `UploadPreviewList` used directly hides delete by default, but via `ButtonUpload`/`DropUpload` it shows delete by default. Please either align these defaults or, if the difference is intentional, ensure the public API docs clearly describe the distinct behaviors.
</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.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7590   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          749       749           
  Lines        32982     32988    +6     
  Branches      4577      4578    +1     
=========================================
+ Hits         32982     32988    +6     
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
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

This PR fixes issue #7587 where the ShowDeleteButton parameter in ButtonUpload component was not working. The delete button was always displayed in UploadPreviewList regardless of the parameter value.

Changes:

  • Added conditional rendering for the delete button in UploadPreviewList based on ShowDeleteButton parameter
  • Moved ShowDeleteButton parameter from FileListUploadBase to individual upload components (ButtonUpload, DropUpload, CardUpload) for better control
  • Set default value to true for ButtonUpload and DropUpload to maintain backward compatibility with existing buggy behavior (button always showed)

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/BootstrapBlazor/Components/Upload/UploadPreviewList.razor.cs Added ShowDeleteButton parameter (default false) to control delete button visibility
src/BootstrapBlazor/Components/Upload/UploadPreviewList.razor Wrapped delete button rendering in conditional check using ShowDeleteButton parameter
src/BootstrapBlazor/Components/Upload/FileListUploadBase.cs Removed ShowDeleteButton parameter from base class to allow individual components to define their own defaults
src/BootstrapBlazor/Components/Upload/DropUpload.razor.cs Added ShowDeleteButton parameter with default true for backward compatibility
src/BootstrapBlazor/Components/Upload/DropUpload.razor Passed ShowDeleteButton parameter to UploadPreviewList component
src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs Added ShowDeleteButton parameter with default false (CardUpload has its own delete button implementation)
src/BootstrapBlazor/Components/Upload/CardUpload.razor Minor whitespace cleanup
src/BootstrapBlazor/Components/Upload/ButtonUpload.razor.cs Added ShowDeleteButton parameter with default true for backward compatibility
src/BootstrapBlazor/Components/Upload/ButtonUpload.razor Passed ShowDeleteButton parameter to UploadPreviewList component

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

@ArgoZhang ArgoZhang merged commit facf7cb into main Jan 27, 2026
6 checks passed
@ArgoZhang ArgoZhang deleted the fix-button branch January 27, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ButtonUpload组件ShowDeleteButton无效

1 participant