mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
fix(button): keyboard does not work when setting false (#1509)
Co-authored-by: unknown <liyang@xiaoyouzi.com> Co-authored-by: 07akioni <07akioni2@gmail.com>
This commit is contained in:
parent
26fc49f233
commit
a28b09c528
@ -10,6 +10,7 @@
|
||||
### Fixes
|
||||
|
||||
- Fix `n-alert` `contentTextColor` and `titleTextColor` type theme variable not working, closes [#1495](https://github.com/TuSimple/naive-ui/issues/1495).
|
||||
- Fix `n-button` `keyboard` prop does not work, closes [#1508](https://github.com/TuSimple/naive-ui/issues/1508).
|
||||
- Fix `n-upload` instance misses `openOpenFileDialog` method.
|
||||
|
||||
### i18n
|
||||
|
@ -10,6 +10,7 @@
|
||||
### Fixes
|
||||
|
||||
- 修复 `n-alert` `contentTextColor` 和 `titleTextColor` 的类型主题变量不起作用,关闭 [#1495](https://github.com/TuSimple/naive-ui/issues/1495)
|
||||
- 修复 `n-button` `keyboard` 属性不起作用,关闭 [#1508](https://github.com/TuSimple/naive-ui/issues/1508)
|
||||
- 修复 `n-upload` 实例缺少 `openOpenFileDialog` 方法
|
||||
|
||||
### i18n
|
||||
|
@ -153,8 +153,10 @@ const Button = defineComponent({
|
||||
switch (e.code) {
|
||||
case 'Enter':
|
||||
case 'NumpadEnter':
|
||||
if (!props.keyboard) return
|
||||
e.preventDefault()
|
||||
if (!props.keyboard) {
|
||||
e.preventDefault()
|
||||
return
|
||||
}
|
||||
enterPressedRef.value = true
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,21 @@ describe('n-button', () => {
|
||||
await inst.trigger('click')
|
||||
expect(onClick).toHaveBeenCalled()
|
||||
})
|
||||
it('keyboard', async () => {
|
||||
const onClick = jest.fn()
|
||||
const inst = mount(NButton, {
|
||||
props: {
|
||||
keyboard: false,
|
||||
onClick
|
||||
}
|
||||
})
|
||||
await inst.trigger('click')
|
||||
expect(onClick).toBeCalledTimes(1)
|
||||
await inst.trigger('keydown.space')
|
||||
expect(onClick).toBeCalledTimes(1)
|
||||
await inst.trigger('keydown.enter')
|
||||
expect(onClick).toBeCalledTimes(1)
|
||||
})
|
||||
it('disabled', async () => {
|
||||
const onClick = jest.fn()
|
||||
const inst = mount(NButton, {
|
||||
|
Loading…
Reference in New Issue
Block a user