Skip to content

Commit

Permalink
Merge pull request #6963 from erwanlfrt/dev/fix-tree-on-filter-value
Browse files Browse the repository at this point in the history
fix: missing last typed letter on filter tree event
  • Loading branch information
tugcekucukoglu authored Dec 27, 2024
2 parents 91e360f + 505c0e7 commit ca31fca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions packages/primevue/src/tree/Tree.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ describe('Tree.vue', () => {
filter: true
}
});

let searchField = wrapper.find('input.p-inputtext');
const key = 't';
searchField.element.value = key;

Check failure on line 53 in packages/primevue/src/tree/Tree.spec.js

View workflow job for this annotation

GitHub Actions / build (18)

Expected blank line before this statement

Check failure on line 53 in packages/primevue/src/tree/Tree.spec.js

View workflow job for this annotation

GitHub Actions / build (20)

Expected blank line before this statement

let searchField = wrapper.find('input.p-inputtext');

await searchField.trigger('keydown.space');
await searchField.trigger('keyup', {
key
});

expect(wrapper.emitted('filter')).toBeTruthy();
expect(wrapper.emitted('filter')[0][0].value).toEqual(key);
});

it('should render icon', ({ expect }) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/primevue/src/tree/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
</template>
<IconField v-if="filter" :unstyled="unstyled" :pt="{ ...ptm('pcFilter'), ...ptm('pcFilterContainer') }" :class="cx('pcFilterContainer')">
<InputText v-model="filterValue" autocomplete="off" :class="cx('pcFilterInput')" :placeholder="filterPlaceholder" :unstyled="unstyled" @keydown="onFilterKeydown" :pt="ptm('pcFilterInput')" />
<InputText v-model="filterValue" autocomplete="off" :class="cx('pcFilterInput')" :placeholder="filterPlaceholder" :unstyled="unstyled" @keyup="onFilterKeyup" :pt="ptm('pcFilterInput')" />
<InputIcon :unstyled="unstyled" :pt="ptm('pcFilterIconContainer')">
<!--TODO: searchicon deprecated since v4.0-->
<slot :name="$slots.filtericon ? 'filtericon' : 'searchicon'" :class="cx('filterIcon')">
Expand Down Expand Up @@ -172,7 +172,7 @@ export default {
isNodeLeaf(node) {
return node.leaf === false ? false : !(node.children && node.children.length);
},
onFilterKeydown(event) {
onFilterKeyup(event) {
if (event.code === 'Enter' || event.code === 'NumpadEnter') {
event.preventDefault();
}
Expand Down

0 comments on commit ca31fca

Please sign in to comment.