|
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>
|
@@ -350,6 +353,26 @@ export default {
|
350 | 353 | } else {
|
351 | 354 | this.editableValueKey = null
|
352 | 355 | }
|
| 356 | + }, |
| 357 | + handleInputNumberKeyDown (event, isDecimal) { |
| 358 | + const allowedCodes = ['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Minus'] |
| 359 | +
|
| 360 | + if (isDecimal) { |
| 361 | + allowedCodes.push('Period') |
| 362 | + } |
| 363 | +
|
| 364 | + if ( |
| 365 | + event.getModifierState('Control') || |
| 366 | + event.getModifierState('Meta') || |
| 367 | + event.getModifierState('Alt') |
| 368 | + ) { |
| 369 | + return |
| 370 | + } |
| 371 | +
|
| 372 | + const isValid = allowedCodes.includes(event.code) || !isNaN(event.key) |
| 373 | + if (!isValid) { |
| 374 | + event.preventDefault() |
| 375 | + } |
353 | 376 | }
|
354 | 377 | }
|
355 | 378 | }
|
|
0 commit comments