Skip to content

Commit acfc4c4

Browse files
committed
refactor: 更新逻辑
1 parent d69d352 commit acfc4c4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/BootstrapBlazor/Components/Input/BootstrapInput.razor.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ export function clear(id) {
77
}
88
}
99

10-
const hasNoModifiers = (e) => !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey;
11-
1210
export function handleKeyUp(id, invoke, enter, enterCallbackMethod, esc, escCallbackMethod) {
1311
const el = document.getElementById(id)
1412
if (el) {
1513
EventHandler.on(el, 'keyup', e => {
16-
if (enter && (e.key === 'Enter' || e.key === 'NumpadEnter') && hasNoModifiers(e)) {
17-
invoke.invokeMethodAsync(enterCallbackMethod, el.value)
14+
if (enter && (e.key === 'Enter' || e.key === 'NumpadEnter')) {
15+
invoke.invokeMethodAsync(enterCallbackMethod, { key: e.key, code: e.code, ctrlKey: e.ctrlKey, shiftKey: e.shiftKey, altKey: e.altKey, metaKey: e.metaKey, repeat: e.repeat, type: e.type, location: e.location }, el.value)
1816
}
1917
else if (esc && e.key === 'Escape') {
2018
invoke.invokeMethodAsync(escCallbackMethod)

src/BootstrapBlazor/Components/Input/BootstrapInputBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6+
using Microsoft.AspNetCore.Components.Web;
7+
68
namespace BootstrapBlazor.Components;
79

810
/// <summary>
@@ -213,7 +215,7 @@ protected virtual async Task OnBlur()
213215
/// </summary>
214216
/// <returns></returns>
215217
[JSInvokable]
216-
public async Task EnterCallback(string val)
218+
public virtual async Task EnterCallback(KeyboardEventArgs e, string val)
217219
{
218220
if (OnEnterAsync != null)
219221
{

0 commit comments

Comments
 (0)