Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.0.2</Version>
</PropertyGroup>

<PropertyGroup>
<PackageTags>Bootstrap Blazor WebAssembly wasm UI Components Sortable</PackageTags>
<Description>Bootstrap UI components extensions of SortableJS</Description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.Components;

/// <summary>
/// SortableEvent 类
/// <para lang="zh">SortableEvent 类</para>
/// <para lang="en">SortableEvent class</para>
/// </summary>
public class SortableEvent
{
/// <summary>
/// 获得/设置 原始项所属容器 Id
/// <para lang="zh">获得/设置 原始项所属容器 Id</para>
/// <para lang="en">Gets or sets the container Id of the original item.</para>
/// </summary>
Comment on lines 7 to 16
Copy link

Choose a reason for hiding this comment

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

suggestion: Using [NotNull] on value-type properties OldIndex and NewIndex is redundant and potentially misleading.

Since OldIndex and NewIndex are non-nullable ints, [NotNull] has no effect here and may imply they can be null. Please remove the attribute from these properties and keep it only on nullable reference-type members like FromId.

Suggested implementation:

    /// <summary>
    /// <para lang="zh">获得/设置 原始索引</para>
    /// <para lang="en">Gets or sets the original index.</para>
    /// </summary>
    public int OldIndex { get; set; }

In the same file (SortableEvent.cs), also remove [NotNull] from any other non-nullable value-type properties such as NewIndex, keeping [NotNull] only on nullable reference-type members like FromId.

[NotNull]
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

SortableEvent.FromId is declared string? but annotated [NotNull], and it is not assigned in TriggerUpdate / TriggerRemove, so it can be null at runtime. Either make this property truly required (non-nullable + set it consistently), or remove [NotNull] and document when it is populated (e.g., only for cross-list Add).

Suggested change
[NotNull]

Copilot uses AI. Check for mistakes.
public string? FromId { get; set; }

/// <summary>
/// 获得/设置 原始索引
/// <para lang="zh">获得/设置 原始索引</para>
/// <para lang="en">Gets or sets the original index.</para>
/// </summary>
[NotNull]
public int OldIndex { get; set; }

Comment on lines 24 to 26
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

[NotNull] on value type properties has no effect (e.g., OldIndex is int and cannot be null). Remove the attribute to avoid implying nullable semantics.

Copilot uses AI. Check for mistakes.
/// <summary>
/// 获得/设置 新索引
/// <para lang="zh">获得/设置 新索引</para>
/// <para lang="en">Gets or sets the new index.</para>
/// </summary>
[NotNull]
public int NewIndex { get; set; }
Comment on lines 31 to 32
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

[NotNull] on value type properties has no effect (e.g., NewIndex is int and cannot be null). Remove the attribute to avoid implying nullable semantics.

Copilot uses AI. Check for mistakes.

/// <summary>
/// 获得/设置 移动元素 <see cref="SortableListItem"/> 集合
/// <para lang="zh">获得 移动元素 <see cref="SortableListItem"/> 集合</para>
/// <para lang="en">Gets the collection of moved <see cref="SortableListItem"/> elements.</para>
/// </summary>
public List<SortableListItem> Items { get; } = [];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

Expand All @@ -8,55 +8,59 @@
namespace BootstrapBlazor.Components;

/// <summary>
/// SortableList 组件
/// <para lang="zh">SortableList 组件</para>
/// <para lang="en">SortableList component</para>
/// </summary>
public partial class SortableList : ISortableList
{
/// <summary>
/// 获得/设置 配置项实例 <see cref="SortableOption"/>
/// <para lang="zh">获得/设置 配置项实例 <see cref="SortableOption"/></para>
/// <para lang="en">Gets or sets the configuration option instance <see cref="SortableOption"/>.</para>
/// </summary>
[Parameter]
public SortableOption? Option { get; set; }

/// <summary>
/// 获得/设置 子组件 必填项不可为空
/// <para lang="zh">获得/设置 子组件 必填项不可为空</para>
/// <para lang="en">Gets or sets the child content. Required and cannot be null.</para>
/// </summary>
[Parameter]
[EditorRequired]
public RenderFragment? ChildContent { get; set; }

/// <summary>
/// 获得/设置 元素更新回调方法
/// <para lang="zh">获得/设置 元素更新回调方法</para>
/// <para lang="en">Gets or sets the callback method when an element is updated.</para>
/// </summary>
[Parameter]
public Func<SortableEvent, Task>? OnUpdate { get; set; }

/// <summary>
/// 获得/设置 元素更新回调方法
/// <para lang="zh">获得/设置 元素移除回调方法</para>
/// <para lang="en">Gets or sets the callback method when an element is removed.</para>
/// </summary>
[Parameter]
public Func<SortableEvent, Task>? OnRemove { get; set; }

/// <summary>
/// 获得/设置 元素增加回调方法
/// <para lang="zh">获得/设置 元素增加回调方法</para>
/// <para lang="en">Gets or sets the callback method when an element is added.</para>
/// </summary>
[Parameter]
public Func<SortableEvent, Task>? OnAdd { get; set; }

private string? ClassString => CssBuilder.Default("bb-sortable")
.AddClassFromAttributes(AdditionalAttributes)
.Build();

/// <summary>
/// <inheritdoc />
/// </summary>
/// <returns></returns>
protected override Task InvokeInitAsync() => InvokeVoidAsync("init", Id, Interop, Option, OnUpdate != null, OnRemove != null, OnAdd != null);

/// <summary>
/// JavaScript 调用触发节点更新方法
/// <para lang="zh">由 JavaScript 调用触发节点更新方法</para>
/// <para lang="en">Called by JavaScript to trigger the node update method.</para>
/// </summary>
/// <returns></returns>
[JSInvokable]
public async Task TriggerUpdate(List<SortableListItem> items)
{
Expand All @@ -75,9 +79,9 @@ public async Task TriggerUpdate(List<SortableListItem> items)
}

/// <summary>
/// JavaScript 调用触发节点更新方法
/// <para lang="zh">由 JavaScript 调用触发节点移除方法</para>
/// <para lang="en">Called by JavaScript to trigger the node remove method.</para>
/// </summary>
/// <returns></returns>
[JSInvokable]
public async Task TriggerRemove(List<SortableListItem> items)
{
Expand All @@ -96,9 +100,9 @@ public async Task TriggerRemove(List<SortableListItem> items)
}

/// <summary>
/// JavaScript 调用触发节点更新方法
/// <para lang="zh">由 JavaScript 调用触发节点增加方法</para>
/// <para lang="en">Called by JavaScript to trigger the node add method.</para>
/// </summary>
/// <returns></returns>
[JSInvokable]
public async Task TriggerAdd(List<SortableListItem> items)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.Components;

/// <summary>
/// SortableListItem 类
/// <para lang="zh">SortableListItem 类</para>
/// <para lang="en">SortableListItem class</para>
/// </summary>
public class SortableListItem
{
/// <summary>
/// 获得/设置 原始项所属容器 Id
/// <para lang="zh">获得/设置 原始项所属容器 Id</para>
/// <para lang="en">Gets or sets the container Id of the original item.</para>
/// </summary>
[NotNull]
Comment on lines +14 to 17
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

SortableListItem.FromId is marked [NotNull] but JS only supplies FromId for the Add callback; for Update/Remove the deserialized items will have FromId == null. Either remove [NotNull] / adjust docs to reflect it is optional, or update the JS payloads to always include FromId.

Suggested change
/// <para lang="zh">获得/设置 原始项所属容器 Id</para>
/// <para lang="en">Gets or sets the container Id of the original item.</para>
/// </summary>
[NotNull]
/// <para lang="zh">获得/设置 原始项所属容器 Id(某些回调中可能为空)</para>
/// <para lang="en">Gets or sets the container Id of the original item (may be null for some callbacks).</para>
/// </summary>

Copilot uses AI. Check for mistakes.
public string? FromId { get; set; }

/// <summary>
/// 获得/设置 原始索引
/// <para lang="zh">获得/设置 原始索引</para>
/// <para lang="en">Gets or sets the original index.</para>
/// </summary>
public int OldIndex { get; set; }

/// <summary>
/// 获得/设置 新索引
/// <para lang="zh">获得/设置 新索引</para>
/// <para lang="en">Gets or sets the new index.</para>
/// </summary>
public int NewIndex { get; set; }
}
Loading