feat(input-number): support keyboard events ArrowUp and ArrowDown opera… (#161)

* feat: InputNumber support keyboard events ArrowUp and ArrowDown operations

* feat: Optimize code
This commit is contained in:
XieZongChen 2021-06-16 23:02:13 +08:00 committed by GitHub
parent f18af1e3f9
commit 47c8c08001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,7 @@
## Feats
- `n-tree` support `disabled` & `checkboxDisabled` on option.
- `n-input-number` support keyboard events ArrowUp and ArrowDown operations.
## Fixes

View File

@ -5,6 +5,7 @@
## Feats
- `n-tree` 选项支持 `disabled` & `checkboxDisabled` 属性
- `n-input-number` 支持键盘的上键和下键操作
## Fixes

View File

@ -293,6 +293,16 @@ export default defineComponent({
if (value !== false) {
inputInstRef.value?.deactivate()
}
} else if (e.code === 'ArrowUp') {
const value = deriveValueFromDisplayedValue()
if (value !== false) {
doAdd()
}
} else if (e.code === 'ArrowDown') {
const value = deriveValueFromDisplayedValue()
if (value !== false) {
doMinus()
}
}
}
function handleUpdateDisplayedValue (value: string): void {