Skip to content

Commit acfc7d4

Browse files
committed
fix(keyup): prevent modifier key combinations from triggering Enter callback
- Add `hasNoModifiers` helper to check for Ctrl/Shift/Alt/Meta keys - Update Enter key handling in `handleKeyUp` to ignore modifier combinations - Retain existing Escape key logic
1 parent 2cf8af4 commit acfc7d4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ export function clear(id) {
77
}
88
}
99

10+
const hasNoModifiers = (e) => !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey;
11+
1012
export function handleKeyUp(id, invoke, enter, enterCallbackMethod, esc, escCallbackMethod) {
1113
const el = document.getElementById(id)
1214
if (el) {
1315
EventHandler.on(el, 'keyup', e => {
14-
if (enter && (e.key === 'Enter' || e.key === 'NumpadEnter')) {
16+
if (enter && (e.key === 'Enter' || e.key === 'NumpadEnter') && hasNoModifiers(e)) {
1517
invoke.invokeMethodAsync(enterCallbackMethod, el.value)
1618
}
1719
else if (esc && e.key === 'Escape') {

0 commit comments

Comments
 (0)