From 9e76c667938aa2d8b5bd66051514c34b05274bb8 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Sat, 4 Jul 2020 14:53:12 +0300 Subject: [PATCH] Fixed #359 - Filter event for Listbox, Dropdown and MultiSelect --- src/components/dropdown/Dropdown.d.ts | 1 + src/components/dropdown/Dropdown.vue | 5 ++++- src/components/listbox/Listbox.d.ts | 1 + src/components/listbox/Listbox.vue | 5 ++++- src/components/multiselect/MultiSelect.d.ts | 1 + src/components/multiselect/MultiSelect.vue | 5 ++++- src/views/dropdown/DropdownDoc.vue | 6 ++++++ src/views/listbox/ListboxDoc.vue | 6 ++++++ src/views/multiselect/MultiSelectDoc.vue | 6 ++++++ 9 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/components/dropdown/Dropdown.d.ts b/src/components/dropdown/Dropdown.d.ts index 17105ce3d..9fbcdb9d3 100755 --- a/src/components/dropdown/Dropdown.d.ts +++ b/src/components/dropdown/Dropdown.d.ts @@ -25,6 +25,7 @@ export declare class Dropdown extends Vue { $emit(eventName: 'before-leave'): this; $emit(eventName: 'show'): this; $emit(eventName: 'hide'): this; + $emit(eventName: 'filter', e: { originalEvent: Event, value: string }): this; $slot: { option: VNode[]; } diff --git a/src/components/dropdown/Dropdown.vue b/src/components/dropdown/Dropdown.vue index cf1b9fcdb..766b48ed4 100755 --- a/src/components/dropdown/Dropdown.vue +++ b/src/components/dropdown/Dropdown.vue @@ -19,7 +19,7 @@
- +
@@ -407,6 +407,9 @@ export default { else document.getElementById(this.appendTo).removeChild(this.$refs.overlay); } + }, + onFilterChange(event) { + this.$emit('filter', {originalEvent: event, value: event.target.value}); } }, computed: { diff --git a/src/components/listbox/Listbox.d.ts b/src/components/listbox/Listbox.d.ts index e50df407f..b53a83b06 100755 --- a/src/components/listbox/Listbox.d.ts +++ b/src/components/listbox/Listbox.d.ts @@ -17,6 +17,7 @@ export declare class Listbox extends Vue { ariaLabelledBy?: string; $emit(eventName: 'input', value: any): this; $emit(eventName: 'change', e: { originalEvent: Event, value: any }): this; + $emit(eventName: 'filter', e: { originalEvent: Event, value: string }): this; $slots: { option: VNode[]; } diff --git a/src/components/listbox/Listbox.vue b/src/components/listbox/Listbox.vue index 6dc940835..9f6bf41da 100755 --- a/src/components/listbox/Listbox.vue +++ b/src/components/listbox/Listbox.vue @@ -2,7 +2,7 @@
- +
@@ -216,6 +216,9 @@ export default { return DomHandler.hasClass(prevItem, 'p-disabled') ? this.findPrevItem(prevItem) : prevItem; else return null; + }, + onFilterChange(event) { + this.$emit('filter', {originalEvent: event, value: event.target.value}); } }, computed: { diff --git a/src/components/multiselect/MultiSelect.d.ts b/src/components/multiselect/MultiSelect.d.ts index 2d4a3d189..5e32fcba1 100755 --- a/src/components/multiselect/MultiSelect.d.ts +++ b/src/components/multiselect/MultiSelect.d.ts @@ -23,6 +23,7 @@ export declare class MultiSelect extends Vue { $emit(eventName: 'before-leave'): this; $emit(eventName: 'show'): this; $emit(eventName: 'hide'): this; + $emit(eventName: 'filter', e: { originalEvent: Event, value: string }): this; $slots: { value: VNode[]; option: VNode[]; diff --git a/src/components/multiselect/MultiSelect.vue b/src/components/multiselect/MultiSelect.vue index 347fc2908..4c249175d 100755 --- a/src/components/multiselect/MultiSelect.vue +++ b/src/components/multiselect/MultiSelect.vue @@ -26,7 +26,7 @@
- +