Skip to content

Commit 5002470

Browse files
authored
refactor(Keydown): remove NumpadEnter check (#6944)
* refactor: 移除 NumpadEnter 判断 * feat: 增加异常保护
1 parent d080648 commit 5002470

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export function init(id, invoke, value, changedEventCallback) {
150150
const handlerKeydown = (ac, e) => {
151151
const key = e.key;
152152
const { el, invoke, menu } = ac;
153-
if (key === 'Enter' || key === 'NumpadEnter') {
153+
if (key === 'Enter') {
154154
const skipEnter = el.getAttribute('data-bb-skip-enter') === 'true';
155155
if (!skipEnter) {
156156
const current = menu.querySelector('.active');

src/BootstrapBlazor/Components/Button/PopConfirmButton.razor.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export function init(id, invoke, closeCallback) {
3939
}
4040
confirm.hide = () => {
4141
const popover = getDescribedElement(el)
42+
if (popover == null) {
43+
return;
44+
}
45+
4246
popover.classList.remove('show')
4347

4448
const children = popover.children

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function handleKeyUp(id, invoke, enter, enterCallbackMethod, esc, escCall
1818
const el = document.getElementById(id)
1919
if (el) {
2020
EventHandler.on(el, 'keyup', e => {
21-
if (enter && (e.key === 'Enter' || e.key === 'NumpadEnter')) {
21+
if (enter && (e.key === 'Enter')) {
2222
const useShiftEnter = el.getAttribute('data-bb-shift-enter') === 'true';
2323
if (!e.shiftKey && useShiftEnter) {
2424
return;

src/BootstrapBlazor/Components/IpAddress/IpAddress.razor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export function init(id) {
6565
selectCell(el, index - 1)
6666
}
6767
}
68-
else if (current.selectionStart === current.value.length && (e.code === 'Space' || e.code === 'ArrowRight')) {
68+
else if (current.selectionStart === current.value.length && (e.key === 'Space' || e.key === 'ArrowRight')) {
6969
e.preventDefault()
7070
selectCell(el, index + 1)
7171
}
72-
else if (current.selectionStart === 0 && e.code === 'ArrowLeft') {
72+
else if (current.selectionStart === 0 && e.key === 'ArrowLeft') {
7373
e.preventDefault()
7474
selectCell(el, index - 1)
7575
}

src/BootstrapBlazor/Components/Select/MultiSelect.razor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export function init(id, invoke, options) {
3737
const triggerSpace = e.target.getAttribute('data-bb-trigger-key') === 'space';
3838
let submit = false;
3939
if (triggerSpace) {
40-
if (e.code === 'Space') {
40+
if (e.key === 'Space') {
4141
submit = true;
4242
}
4343
}
44-
else if (e.code === 'Enter' || e.code === 'NumPadEnter') {
44+
else if (e.key === 'Enter') {
4545
submit = true;
4646
}
4747

src/BootstrapBlazor/Components/Textarea/Textarea.razor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function init(id) {
1111

1212
Data.set(id, text);
1313
EventHandler.on(el, 'keydown', e => {
14-
if (e.key === "Enter" || e.key === "NumpadEnter") {
14+
if (e.key === "Enter") {
1515
const useShiftEnter = el.getAttribute('data-bb-shift-enter') === 'true';
1616
const shiftKey = e.shiftKey;
1717
if (useShiftEnter && shiftKey === false) {

src/BootstrapBlazor/wwwroot/modules/base-select.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const initKeydownHandler = select => {
2929
const keydown = e => {
3030
const menu = popover.toggleMenu;
3131
const key = e.key;
32-
if (key === "Enter" || key === 'NumpadEnter') {
32+
if (key === "Enter") {
3333
if (popover.isPopover) {
3434
popover.hide();
3535
}

0 commit comments

Comments
 (0)