From fc3f88b958e3513608ef0e8303b60ca27f0aa4bb Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 6 Jan 2025 14:26:41 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoComplete/AutoComplete.razor.js | 28 ++++++++----------- .../Components/Select/Select.razor.js | 2 +- .../Components/TreeView/TreeView.razor.js | 2 +- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js index fb863319cab..50b27ff853e 100644 --- a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js +++ b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js @@ -26,6 +26,7 @@ export function init(id, invoke) { if (duration > 0) { ac.debounce = true EventHandler.on(input, 'keyup', debounce(e => { + e.preventDefault(); handlerKeyup(ac, e); }, duration, e => { return ['ArrowUp', 'ArrowDown', 'Escape', 'Enter', 'NumpadEnter'].indexOf(e.key) > -1 @@ -33,6 +34,8 @@ export function init(id, invoke) { } else { EventHandler.on(input, 'keyup', e => { + e.stopPropagation(); + e.preventDefault(); handlerKeyup(ac, e); }) } @@ -127,26 +130,12 @@ const handlerKeyup = (ac, e) => { else if (index > items.length - 1) { index = 0; } - items[index].classList.add('active'); - const top = getTop(menu, index); - const hehavior = el.getAttribute('data-bb-scroll-behavior') ?? 'smooth'; - menu.scrollTo({ top: top, left: 0, behavior: hehavior }); + current = items[index]; + current.classList.add('active'); + scrollIntoView(el, current); } } -const getTop = (menu, index) => { - const styles = getComputedStyle(menu) - const maxHeight = parseInt(styles.maxHeight) / 2 - const itemHeight = getHeight(menu.querySelector('.dropdown-item')) - const height = itemHeight * index - const count = Math.floor(maxHeight / itemHeight); - let top = 0; - if (height > maxHeight) { - top = itemHeight * (index > count ? index - count : index) - } - return top; -} - export function showList(id) { const ac = Data.get(id) if (ac) { @@ -177,4 +166,9 @@ export function dispose(id) { } } +const scrollIntoView = (el, item) => { + const behavior = el.getAttribute('data-bb-scroll-behavior') ?? 'smooth'; + item.scrollIntoView({ behavior: behavior, block: "nearest", inline: "start" }); +} + export { handleKeyUp, select, selectAllByFocus, selectAllByEnter } diff --git a/src/BootstrapBlazor/Components/Select/Select.razor.js b/src/BootstrapBlazor/Components/Select/Select.razor.js index 109f918572d..83fec1d5f75 100644 --- a/src/BootstrapBlazor/Components/Select/Select.razor.js +++ b/src/BootstrapBlazor/Components/Select/Select.razor.js @@ -141,5 +141,5 @@ function indexOf(el, element) { const scrollIntoView = (el, item) => { const behavior = el.getAttribute('data-bb-scroll-behavior') ?? 'smooth'; - item.scrollIntoView({ behavior: behavior, block: "center", inline: "nearest" }); + item.scrollIntoView({ behavior: behavior, block: "nearest", inline: "start" }); } diff --git a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.js b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.js index 1066abe6cc6..2d9499ef182 100644 --- a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.js +++ b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.js @@ -32,7 +32,7 @@ export function scroll(id, options) { const el = document.getElementById(id); const item = el.querySelector(".tree-content.active"); if (item) { - item.scrollIntoView(options ?? { behavior: 'smooth', block: 'start', inline: 'nearest' }); + item.scrollIntoView(options ?? { behavior: 'smooth', block: 'nearest', inline: 'start' }); } } From 74359d9517d6d5048847c088f74a7f728906f546 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 6 Jan 2025 14:31:55 +0800 Subject: [PATCH 2/6] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=20TableSection=20?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B=E6=BB=9A=E5=8A=A8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/Table/TablesSelection.razor.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/Table/TablesSelection.razor.js b/src/BootstrapBlazor.Server/Components/Samples/Table/TablesSelection.razor.js index 1272517f2e3..31c11ef5be3 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Table/TablesSelection.razor.js +++ b/src/BootstrapBlazor.Server/Components/Samples/Table/TablesSelection.razor.js @@ -1,12 +1,9 @@ export function scroll(id) { const element = document.getElementById(id); if (element) { - const selectedRow = element.querySelector('.form-check.is-checked'); + const selectedRow = element.querySelector('tr.active'); if (selectedRow) { - const row = selectedRow.closest('tr'); - if (row) { - row.scrollIntoView({ behavior: 'smooth', block: 'center' }); - } + selectedRow.scrollIntoView({ behavior: 'smooth', block: 'center' }); } } } From 481cbd736b417d45ca745bdb88934a6bb6519c27 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 6 Jan 2025 14:37:31 +0800 Subject: [PATCH 3/6] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs index a941c657111..eb24f9a8fb7 100644 --- a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs +++ b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs @@ -258,7 +258,7 @@ public partial class TreeView : IModelEqualityComparer public bool EnableKeyboard { get; set; } /// - /// 获得/设置 是否键盘上下键操作当前选中节点与视窗关系配置 默认 null 使用 { behavior: "smooth", block: "center", inline: "nearest" } + /// 获得/设置 是否键盘上下键操作当前选中节点与视窗关系配置 默认 null 使用 { behavior: "smooth", block: "nearest", inline: "nearest" } /// [Parameter] public ScrollIntoViewOptions? ScrollIntoViewOptions { get; set; } From a8a434ef33c5831f522110ad4e6d3e769126d168 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 6 Jan 2025 14:37:43 +0800 Subject: [PATCH 4/6] chore: bump version 9.2.5-beta02 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 1e12295db6c..374b1505436 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 9.2.5-beta01 + 9.2.5-beta02 From 70de728d10295bdd93fe8c528cfc8045e6f539b1 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 6 Jan 2025 14:41:37 +0800 Subject: [PATCH 5/6] =?UTF-8?q?revert:=20=E6=92=A4=E9=94=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/AutoComplete/AutoComplete.razor.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js index 50b27ff853e..680a7ce0532 100644 --- a/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js +++ b/src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js @@ -26,7 +26,6 @@ export function init(id, invoke) { if (duration > 0) { ac.debounce = true EventHandler.on(input, 'keyup', debounce(e => { - e.preventDefault(); handlerKeyup(ac, e); }, duration, e => { return ['ArrowUp', 'ArrowDown', 'Escape', 'Enter', 'NumpadEnter'].indexOf(e.key) > -1 @@ -34,8 +33,6 @@ export function init(id, invoke) { } else { EventHandler.on(input, 'keyup', e => { - e.stopPropagation(); - e.preventDefault(); handlerKeyup(ac, e); }) } From c9453fcf82127605decdd88b939bfad2955dfe31 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 6 Jan 2025 14:44:28 +0800 Subject: [PATCH 6/6] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs index eb24f9a8fb7..8787476f1cf 100644 --- a/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs +++ b/src/BootstrapBlazor/Components/TreeView/TreeView.razor.cs @@ -258,7 +258,7 @@ public partial class TreeView : IModelEqualityComparer public bool EnableKeyboard { get; set; } /// - /// 获得/设置 是否键盘上下键操作当前选中节点与视窗关系配置 默认 null 使用 { behavior: "smooth", block: "nearest", inline: "nearest" } + /// 获得/设置 是否键盘上下键操作当前选中节点与视窗关系配置 默认 null 使用 { behavior: "smooth", block: "nearest", inline: "start" } /// [Parameter] public ScrollIntoViewOptions? ScrollIntoViewOptions { get; set; }