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
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.1.9-beta08</Version>
<Version>9.1.9-beta09</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ protected override void OnParametersSet()
protected override async Task OnParametersSetAsync()
{
_rows = null;
TreeNodeStateCache.Reset();

if (Items != null)
{
Expand Down Expand Up @@ -875,12 +876,12 @@ private List<TreeViewItem<TItem>> Rows
get
{
// 扁平化数据集合
_rows ??= GetItems().ToFlat<TItem>();
_rows ??= GetTreeItems().ToFlat<TItem>();
return _rows;
}
}

private List<TreeViewItem<TItem>> GetItems() => _searchItems ?? Items;
private List<TreeViewItem<TItem>> GetTreeItems() => _searchItems ?? Items;

private static string? GetTreeRowStyle(TreeViewItem<TItem> item)
{
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/TreeView/TreeView.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function scroll(id, options) {
const el = document.getElementById(id);
const item = el.querySelector(".tree-content.active");
if (item) {
item.parentElement.scrollTo({ top: item.offsetTop, left: 0, behavior: options?.behavior ?? 'smooth' });
item.scrollIntoView(options ?? { behavior: 'smooth', block: 'start', inline: 'nearest' });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
.tree-root {
padding: var(--bb-tree-padding);
margin: var(--bb-tree-margin);
position: relative;
}

.tree-content {
Expand Down
6 changes: 4 additions & 2 deletions src/BootstrapBlazor/Extensions/TreeViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ public static class TreeViewExtensions
/// </summary>
/// <typeparam name="TItem"></typeparam>
/// <param name="source"></param>
/// <param name="parent"></param>
/// <returns></returns>
public static List<TreeViewItem<TItem>> ToFlat<TItem>(this IEnumerable<TreeViewItem<TItem>> source)
public static List<TreeViewItem<TItem>> ToFlat<TItem>(this IEnumerable<TreeViewItem<TItem>> source, TreeViewItem<TItem>? parent = null)
{
var rows = new List<TreeViewItem<TItem>>();
if (source != null)
{
foreach (var item in source)
{
item.Parent = parent;
rows.Add(item);
if (item.IsExpand)
{
rows.AddRange(ToFlat(item.Items));
rows.AddRange(ToFlat(item.Items, item));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/BootstrapBlazor/Options/ScrollIntoViewOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ namespace BootstrapBlazor.Components;
public class ScrollIntoViewOptions
{
/// <summary>
/// 获得/设置 滚动条宽度 默认 5px
/// Determines whether scrolling is instant or animates smoothly
/// </summary>
public ScrollIntoViewBehavior Behavior { get; set; }

/// <summary>
/// 获得/设置 滚动条鼠标悬浮宽度 默认 5px
/// Defines the vertical alignment of the element within the scrollable ancestor container
/// </summary>
public ScrollIntoViewBlock Block { get; set; }

/// <summary>
/// 获得/设置 滚动条鼠标悬浮宽度 默认 5px
/// Defines the horizontal alignment of the element within the scrollable ancestor container
/// </summary>
public ScrollIntoViewInline Inline { get; set; }
}
Expand Down
Loading