mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-10 09:22:34 +00:00
Merge pull request #3998 from thielpa/fix-inputnumber
fix(TreeNode): stop keydown event propagation from content
This commit is contained in:
commit
2159c3cc88
2 changed files with 46 additions and 1 deletions
45
components/lib/tree/Tree.spec.js
Normal file
45
components/lib/tree/Tree.spec.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { mount } from '@vue/test-utils';
|
||||
import PrimeVue from 'primevue/config';
|
||||
import { nextTick } from 'vue';
|
||||
import Tree from './Tree.vue';
|
||||
|
||||
describe('Tree.vue', () => {
|
||||
let wrapper;
|
||||
|
||||
beforeEach(async () => {
|
||||
wrapper = mount(Tree, {
|
||||
props: {
|
||||
value: [
|
||||
{
|
||||
key: '0',
|
||||
label: 'Documents',
|
||||
data: 'Documents Folder',
|
||||
icon: 'pi pi-fw pi-inbox',
|
||||
children: []
|
||||
}
|
||||
]
|
||||
},
|
||||
slots: {
|
||||
default: `<input data-tree-input />`
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should exists', () => {
|
||||
expect(wrapper.find('.p-tree.p-component').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('triggers event', async () => {
|
||||
wrapper.trigger('keydown.space');
|
||||
expect(wrapper.emitted('keydown')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('stops event propagation from content', async () => {
|
||||
// If the event propagation is not stopped from content, then inputs would not work as expected
|
||||
let textInput = wrapper.find('input[data-tree-input]');
|
||||
|
||||
await textInput.trigger('keydown.space');
|
||||
|
||||
expect(wrapper.emitted('keydown')).toBeFalsy();
|
||||
});
|
||||
});
|
|
@ -27,7 +27,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<span :class="cx('nodeIcon')" v-bind="getPTOptions('nodeIcon')"></span>
|
||||
<span :class="cx('label')" v-bind="getPTOptions('label')">
|
||||
<span :class="cx('label')" v-bind="getPTOptions('label')" @keydown.stop>
|
||||
<component v-if="templates[node.type] || templates['default']" :is="templates[node.type] || templates['default']" :node="node" />
|
||||
<template v-else>{{ label(node) }}</template>
|
||||
</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue