Skip to content

Commit 14a3099

Browse files
authored
refactor(TreeView): prevent space key default action (#4353)
* doc: 更新示例增加垂直滚动条 * refactor: 阻止空格默认行为 * chore: bump version 8.9.4-beta04
1 parent 9938de3 commit 14a3099

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/BootstrapBlazor.Server/Components/Samples/TreeViews.razor

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@
194194
Introduction="@Localizer["TreeViewEnableKeyboardArrowUpDownIntro"]"
195195
Name="Normal">
196196
<section ignore>@_selectedValue</section>
197-
<TreeView TItem="TreeFoo" Items="@KeyboardItems" OnTreeItemClick="@OnTreeItemKeyboardClick" EnableKeyboard="true" />
197+
<TreeView TItem="TreeFoo" Items="@KeyboardItems" OnTreeItemClick="@OnTreeItemKeyboardClick" style="height: 160px;"
198+
EnableKeyboard="true" ClickToggleNode="false" ClickToggleCheck="false" ShowCheckbox="true" />
198199
</DemoBlock>
199200

200201
<AttributeTable Items="@GetAttributes()"></AttributeTable>

src/BootstrapBlazor/BootstrapBlazor.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>8.9.4-beta03</Version>
4+
<Version>8.9.4-beta04</Version>
55
</PropertyGroup>
66

77
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">

src/BootstrapBlazor/Components/TreeView/TreeView.razor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export function init(id, invoke, method) {
3434
const v = el.getAttribute('data-bb-keyboard');
3535
if (v === "true") {
3636
e.preventDefault();
37-
3837
invoke.invokeMethodAsync(method, e.key);
3938
}
4039
}
@@ -43,6 +42,7 @@ export function init(id, invoke, method) {
4342
if (v === "true") {
4443
const checkbox = el.querySelector(".active > .tree-content > .form-check > .form-check-input");
4544
if (checkbox) {
45+
e.preventDefault();
4646
checkbox.click();
4747
}
4848
}

0 commit comments

Comments
 (0)