|
39 | 39 | @keydown.esc="editableValueKey = null" |
40 | 40 | @pressEnter="updateConfigurationValue(configrecord)" |
41 | 41 | @change="value => setConfigurationEditable(configrecord, value)" |
| 42 | + @keydown="e => handleInputNumberKeyDown(e, false)" |
42 | 43 | /> |
43 | 44 | </a-tooltip> |
44 | 45 | </span> |
|
52 | 53 | @keydown.esc="editableValueKey = null" |
53 | 54 | @pressEnter="updateConfigurationValue(configrecord)" |
54 | 55 | @change="value => setConfigurationEditable(configrecord, value)" |
| 56 | + @keydown="e => handleInputNumberKeyDown(e, true)" |
55 | 57 | /> |
56 | 58 | </a-tooltip> |
57 | 59 | </span> |
|
87 | 89 | @keydown.esc="editableValueKey = null" |
88 | 90 | @pressEnter="updateConfigurationValue(configrecord)" |
89 | 91 | @change="value => setConfigurationEditable(configrecord, value)" |
| 92 | + @keydown="e => handleInputNumberKeyDown(e, true)" |
90 | 93 | /> |
91 | 94 | </a-tooltip> |
92 | 95 | </a-col> |
@@ -365,6 +368,26 @@ export default { |
365 | 368 | } else { |
366 | 369 | this.editableValueKey = null |
367 | 370 | } |
| 371 | + }, |
| 372 | + handleInputNumberKeyDown (event, isDecimal) { |
| 373 | + const allowedCodes = ['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Minus'] |
| 374 | +
|
| 375 | + if (isDecimal) { |
| 376 | + allowedCodes.push('Period') |
| 377 | + } |
| 378 | +
|
| 379 | + if ( |
| 380 | + event.getModifierState('Control') || |
| 381 | + event.getModifierState('Meta') || |
| 382 | + event.getModifierState('Alt') |
| 383 | + ) { |
| 384 | + return |
| 385 | + } |
| 386 | +
|
| 387 | + const isValid = allowedCodes.includes(event.code) || !isNaN(event.key) |
| 388 | + if (!isValid) { |
| 389 | + event.preventDefault() |
| 390 | + } |
368 | 391 | } |
369 | 392 | } |
370 | 393 | } |
|
0 commit comments